cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
We've been busy working on some major updates to the Community, so check out what's changing, what’s staying the same and what you can expect from the Dropbox Community right here.

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: 

How to Use Dropbox API to Organize and Save Files from External URLs?

How to Use Dropbox API to Organize and Save Files from External URLs?

ABDUL Salam
Explorer | Level 3
Go to solution

Hello Forum Members,

I have a project where I receive public URLs of files, and I need to save these files to a specific folder structure in Dropbox. The folder structure in Dropbox should be organized as follows: Parent > Year (dynamic) > Month (dynamic) > Number tokens (dynamic).

I'm wondering if it's possible to achieve this using the Dropbox API. Specifically, I want to be able to pass a URL to the API, and it should download the file and place it in the correct folder structure within Dropbox. If any of the dynamic directories (Year, Month, Number tokens) already exist, I'd like it to insert the file there without creating duplicate folders.

Could someone please point me in the right direction regarding which Dropbox API endpoints to use for such scenario? Has anyone had experience with a similar use case or can provide guidance on how to implement this with the Dropbox API? Any help or insights would be greatly appreciated.

Thank you in advance for your assistance!

1 Accepted Solution

Accepted Solutions

Greg-DB
Dropbox Staff
Go to solution

Dropbox does offer an API endpoint /2/files/save_url which allows you to specify a particular URL to a file and a path where you'd like to save that file in the connected Dropbox account. You can supply the public URL, and programmatically build the desired destination path in your code.

 

By the way, that's a link to the documentation for the HTTPS endpoints themselves, but we recommend using one of the official SDKs if possible. Those have corresponding native methods for the HTTPS endpoints.

 

That sounds like that would work for your use case, so I suggest trying that out. The API Explorer is a good way to test and prototype calls like this.

View solution in original post

5 Replies 5

Greg-DB
Dropbox Staff
Go to solution

Dropbox does offer an API endpoint /2/files/save_url which allows you to specify a particular URL to a file and a path where you'd like to save that file in the connected Dropbox account. You can supply the public URL, and programmatically build the desired destination path in your code.

 

By the way, that's a link to the documentation for the HTTPS endpoints themselves, but we recommend using one of the official SDKs if possible. Those have corresponding native methods for the HTTPS endpoints.

 

That sounds like that would work for your use case, so I suggest trying that out. The API Explorer is a good way to test and prototype calls like this.

ABDUL Salam
Explorer | Level 3
Go to solution

Hi Greg DB,

Thank you for your helpful response! I greatly appreciate the guidance.

It's great to know that Dropbox offers the /2/files/save_url API endpoint, which seems to align perfectly with my use case. I'll definitely look into using this endpoint to save files from the provided URLs to the desired Dropbox folder structure.

I'll also take your advice and explore the official SDKs for Dropbox.

I'll give the API Explorer a try for testing and prototyping as well.

Once again, thank you for pointing me in the right direction. Your assistance has been invaluable!

Thanks!

ABDUL Salam
Explorer | Level 3
Go to solution

Hi Greg,
Your previous response helped me a lot in addressing my requirement, thanks for that. Also, I was curious if a file saved already exists using this endpoint, then it updates the name and appends it with a counter filename(1)? Is there any possibility to completely override the file if it already exists?

Greg-DB
Dropbox Staff
Go to solution

@ABDUL Salam No, unfortunately the /2/files/save_url endpoint doesn't offer "write mode" options, e.g., to overwrite an existing file at the specified location, like /2/files/upload does. I'll pass this along as a feature request, but I can't promise if or when that might be implemented. 

ABDUL Salam
Explorer | Level 3
Go to solution

Thank you, @Greg-DB, for your prompt response. I greatly appreciate your willingness to consider this as a feature request, as it has the potential to provide significant benefits in numerous use cases.

Need more support?
Who's talking

Top contributors to this post

  • User avatar
    ABDUL Salam Explorer | Level 3
  • User avatar
    Greg-DB Dropbox Staff
What do Dropbox user levels mean?