Need to see if your shared folder is taking up space on your dropbox 👨💻? Find out how to check here.
Forum Discussion
Vohry
5 years agoNew member | Level 2
How to download file from picker without node.js?
Hi,
I am wondering about how to download file from Dropbox chooser without node.js.
This is my JS:
options = {
success: function(files) {
// Download
var filenames = files.map(x => x.name);
var fileids = files.map(x => x.id);
$.post("/API/dropbox-download", {Path: "3D_objects", Filenames: filenames, Fileids: fileids}, function(response) {
console.log(response);
});
},
cancel: function() {
},
linkType: "preview",
multiselect: false,
extensions: ['.stl'],
folderselect: false,
sizeLimit: 128000000
};
function UploadFilesFromDropbox_upload1()
{
Dropbox.choose(options);
}
This script works good, but it only gives me a link to file, but I can't download it from code because download button must be pressed. I saw in documentation, that is possible to download file by id by http, so i wrote this code id PHP:
$curl = curl_init("https://content.dropboxapi.com/2/files/download");
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HTTPHEADER, array(
'Authorization: Bearer <Access token>',
'Dropbox-API-Arg: {"path": "id:<Id>"}',
'Content-Type: text/plain'
));
$response = curl_exec($curl);
curl_close($curl);
header("HTTP/1.1 200 OK");
echo $response;
How can I get access token? There is Oauth for it, but Does I need to do Ouath before every chossing? I saw there is SDK on github, but it is installed through npm for node.js, is it possible to use SDK without node.js like google drive picker?
1 Reply
- Greg-DB5 years ago
Dropbox Community Moderator
When using the Dropbox Chooser, it will return the link to each selected file in the "link" field of the returned object for each file.
I see you're using "linkType" of "preview" here. If you just want to download the selected file data, you should use a "linkType" of "direct" instead. That will make the returned "link" a temporary direct link, which you can access directly to get the file data, without using the Dropbox API. That is, you can issue a standard HTTP GET request (either client-side in the browser, or server-side from your server) to retrieve the linked file data.
About Discuss Dropbox Developer & API
Make connections with other developers
The Dropbox Community team is active from Monday to Friday. We try to respond to you as soon as we can, usually within 2 hours.
If you need more help you can view your support options (expected response time for an email or ticket is 24 hours), or contact us on X, Facebook or Instagram.
For more info on available support options for your Dropbox plan, see this article.
If you found the answer to your question in this Community thread, please 'like' the post to say thanks and to let us know it was useful!