cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Tell us what you want to see on the Community here!
Close

Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

File download using v2 in PHP

Highlighted

File download using v2 in PHP

New member | Level 2

Hello,

Am trying to download file from dropbox using dropbox api-PHP.

I have a sharelink generated using dropbox api

$dropbox->postToAPI

is "https://www.dropbox.com/s/bs69w68dwoiiu2q/img0007cade2gtw.jpg?raw=1".

Am not able to download file from dropbox using

$dropbox->download(url);

 

2 Replies 2
Highlighted

Re: File download using v2 in PHP

Dropboxer

Note that Dropbox does not have an officially supported SDK in PHP, so if you have any SDK specific questions, you will need to ask the developer who authored the SDK. 

It appears that you might be using the "kunalvarma05/dropbox-php-sdk".  If that is the case, I suggest reading their wiki page on Uploading and Downloading files (https://github.com/kunalvarma05/dropbox-php-sdk/wiki/Upload-and-Download-Files) as it has some helpful examples.

Looking at your example, there are two ways you can possibly solve your problem.

1)  Because you have already created a shared link with the API, you do not need to use the "download()" method.  The link you have posted above can be downloaded with any PHP library or function for accessing a URL on the web.  The file_get_contents() (http://php.net/manual/en/function.file-get-contents.php) method appears to be a very commonly used approach for downloading a file with a url.

2) Downloading a file does not require creating a shared link first.  If you know the path of the file you wish to download, you can use the path of the file within Dropbox to download directly. Assuming you are using the "kunalvarma05/dropbox-php-sdk", the usage would be:

$dropbox->download(<path of file in dropbox>, <path to save locally>)
Highlighted

Re: File download using v2 in PHP

Dropboxer

A third possible solution would be to use the sharing/get_shared_link_file API method.  This takes a "url" parameter that would match the shared link URL in your original post, and will return the raw bytes of the file referenced by the shared link.  This approach would be similar to my suggestion #1 in my previous reply.

Work Smarter with Dropbox

The way we work is changing. Share and discover new ways to work smarter with Dropbox in our community.

Sound good? Let's get started.
Who's talking

Top contributors to this post

What do Dropbox user levels mean?
Need more support?