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?