Reputation: 7241
In the document of Dropbox Chooser we can get a share page url from files[0].link
, but we need direct download link. How do I get it?
Upvotes: 4
Views: 5144
Reputation: 7241
I found the solution in the forum.
Added data-link-type="direct"
attribute for the Dropbox chooser button.
<input type="dropbox-chooser" name="selected-file" data-link-type="direct" style="visibility:hidden"/>
Update In 2024, this is what you need to use. linkType="direct"
gives you direct download URL for the selected files in Dropbox Chooser.
let options = {
linkType: "direct",
// Required. Called when a user selects an item in the Chooser.
success: function(files) {
alert("Here's the direct file link: " + files[0].link)
},
// Optional. Called when the user closes the dialog without selecting a file
// and does not include any parameters.
cancel: function() {
},
// Optional. A value of false (default) limits selection to a single file, while
// true enables multiple file selection.
multiselect: false, // or true
// Optional. This is a list of file extensions. If specified, the user will
// only be able to select files with these extensions. You may also specify
// file types, such as "video" or "images" in the list. For more information,
// see File types below. By default, all extensions are allowed.
extensions: ['.pdf', '.doc', '.docx'],
// Optional. A value of false (default) limits selection to files,
// while true allows the user to select both folders and files.
// You cannot specify `linkType: "direct"` when using `folderselect: true`.
folderselect: false, // or true
// Optional. A limit on the size of each file that may be selected, in bytes.
// If specified, the user will only be able to select files with size
// less than or equal to this limit.
// For the purposes of this option, folders have size zero.
sizeLimit: 1024, // or any positive number
};
var button = Dropbox.createChooseButton(options);
document.getElementById("container").appendChild(button);
Source - https://www.dropbox.com/developers/chooser
Upvotes: 4