cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Want to know all about tools for creatives that work seamlessly with Dropbox, like Adobe? Well, check it out 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: 

Best way to get a file's URL

Best way to get a file's URL

Not applicable

I am making an iOS app that displays all of the images from a selected folder. To make caching the images easier and more efficient I'm using the SDWebImage Library. SDWebImage requires a URL and I'm currently using the getTemporaryLink function to get a link for each image in the folder. Is there a better way to get a URL? I'm concerned that the links expiring will cause issues. 

1 Accepted Solution

Accepted Solutions

Re: Best way to get a file's URL

Greg-DB
Dropboxer
That is the right way to get a direct link to a file using the API.

I'll be happy to pass along as feedback or feature requests though. What specifically would be more useful? Thanks in advance!

View solution in original post

24 Replies 24

Re: Best way to get a file's URL

Greg-DB
Dropboxer
That is the right way to get a direct link to a file using the API.

I'll be happy to pass along as feedback or feature requests though. What specifically would be more useful? Thanks in advance!

View solution in original post

Re: Best way to get a file's URL

SianZeng
New member | Level 2

I've been trying to find a way to share an image url from dropbox so that I can use it in my newsletters. Something like what imgur does.

I tested it by copying a shared link from dropbox but it didn't work. Is there a way to share image url-s from dropbox. Since Dropbox hosts our images anyway wouldn't be so difficult I thought. 

Re: Best way to get a file's URL

Greg-DB
Dropboxer

SianZeng, can you elaborate on what didn't work? It sounds like you may want to use the options documented here:

https://help.dropbox.com/desktop-web/force-download

Re: Best way to get a file's URL

mikemalter
Helpful | Level 5

I may not be thinking about this correctly, so I'm open to alternatives.  I need to generate a document that lists all of the files and folders off of a selected Dropbox folder.  This I can do now with no issues.  One additional requirement is that the list be hyperlinked so if someone clicks on a link, that document will open.  I could have file hyperlinks for our desktop users, but what about mobile phone users?  I'm thinking that I'll need URL's for that.  So I need to know how to get URL's for selected files.  However, one of the messages above talks about links expiring.  Is there a way to get a permanant URL that can be stored in a document?

 

Thanks.

Re: Best way to get a file's URL

Greg-DB
Dropboxer

@mikemalter It sounds like Dropbox shared links might be a good solution for your use case. They don't expire (though they can be manually revoked). You can create them programmatically using the API via /2/sharing/create_shared_link_with_settings (or a corresponding method if you're using an official SDK).

Re: Best way to get a file's URL

mikemalter
Helpful | Level 5

@Greg K., thanks for your answer.  Of course I have a few more questions.

 

  1. If our group's content manager set up shared folders, is that the same thing as shared files?  Do we have to create a shared link to every file?
  2. I looked at the Json code to create a shared link and I'm wondering can I do the same thing in C#?  I have not coded anything in Json at this point.
  3. I noticed that there did not seem to be anyway to get a copy of the link for a file.  Is there a way to query dropbox and get the shared links of all files that exist?

Thanks for your help.  I am so new to this that my questions might not make sense, but hopefully you'll see what I'm up to and can answer accordingly.

 

 

Re: Best way to get a file's URL

Greg-DB
Dropboxer

@mikemalter No problem:

1. No, shared folders are not the same as shared links. There's a help center article that covers these two different kinds of sharing here: 

https://help.dropbox.com/files-folders/share-file-or-folder

2. Yes, you can call the API from essentially any platform where you can make arbitrary HTTPS calls.  If you're using C#, we recommend using the official Dropbox API v2 .NET SDK, if you can. The SDK will do most of the work for you. For example, it has a CreateSharedLinkWithSettingsAsync method for /2/sharing/create_shared_link_with_settings.

3. Yes, you can retrieve existing shared links using /2/sharing/list_shared_links (which is ListSharedLinksAsync in the .NET SDK).

Re: Best way to get a file's URL

mikemalter
Helpful | Level 5

Hi Greg,

 

If I create a shared link to a folder, that does not mean that all of it's contents now have shared links. Please confirm my understanding that it's a one to one thing.  Thanks.

 

Also, some nuances with regard to shared links.  Let's say on Monday I programattically create shared links for all files and folders in our Dropbox.  Then someone adds new files and folders.  Can I run the same program that basically gets each item and assigns a shared link to it, or do I need to differentiate between those items who do not have a shared link and create a shared link.  Will it mess anything up if I just run my shared link utility on our whole dropbox each time?  I want to make sure I don't create issues on the back end for anyone.

 

Finally the first parameter for CreateSharedLinkWithSettingsAsync is the path of the item.  So the path to an example file is "C:\Users\malter.JOYOUSLIVING\Dropbox\FoldernameLevel1\FolderNameLevel1\FileName.pdf".  Is this what I pass, or do I pass the stuff just after Dropbox, or do I include Dropbox.  I don't see any example code, so I'm having to wing this.  Are there code examples?

 

Thanks.

Re: Best way to get a file's URL

Greg-DB
Dropboxer

If you create a shared link to a folder, that link is specifically for the folder. However, that link does also enable access to the contents of that folder.

 

If you attempt to create a shared link for a file or folder that already has a shared link, the call will fail with an error. You can catch that error though. I illustrated that as well as the path question here in the issue you opened for the .NET SDK:

 

https://github.com/dropbox/dropbox-sdk-dotnet/issues/64

 

Hope this helps! 

Poll
Do you work or study in the creative industry? If so, which area?
If you use Adobe, don't forget to check out our latest integrations update here.
Who's talking

Top contributors to this post

  • User avatar
    Greg-DB Dropboxer
  • User avatar
    lenner90 Explorer | Level 3
  • User avatar
    iCodes Explorer | Level 3
What do Dropbox user levels mean?
Need more support?