You might see that the Dropbox Community team have been busy working on some major updates to the Community itself! So, here is some info on what’s changed, what’s staying the same and what you can expect from the Dropbox Community overall.
Forum Discussion
PerOstergren
4 years agoExplorer | Level 4
SwiftyDropbox: copy files from shared folder link to App folder, or download to local Documents
Very new to the platform, all help appreciated. My aim is to populate my iOS app with some files that originally resides in a shared Dropbox folder, either by downloading them to the local device...
- 4 years ago
To download a file from a shared link for a folder to the local device, you should use listFolder/listFolderContinue, to list the contents of the linked folder, and then getSharedLinkFile to download any needed file(s). When calling getSharedLinkFile, the 'path' should be the path of the file you want to download, relative to the linked folder, and the 'url' should be the shared link for the folder. You can determine the relative path from the metadata returned by listFolder/listFolderContinue, from the Metadata.name for the needed file(s). For example, if it's a file named "file.ext" in the linked folder, the path would be "/file.ext". Or, if it's nested in a subfolder named "subfolder" in the linked folder, the path would be "/subfolder/file.ext".
Alternatively, you can save a file from a shared link for a folder directly to a connected Dropbox account by using getSharedLinkMetadata and saveUrl. You would call getSharedLinkMetadata with the 'url' and 'path' value (built the same was as above), to get the resulting SharedLinkMetadata.url for the specific file in the linked folder that you want. Then you would pass that to saveUrl as 'url' to save that file to the connected account.
However, note that unfortunately there is currently a bug that will prevent getSharedLinkFile and getSharedLinkMetadata from working if your app has the "app folder" access type. That's currently open with engineering, but I don't have a timeline for a fix.
PerOstergren
Explorer | Level 4
Thank you for the push in the right direction, Greg-Db! Had created the App folder only alternative, have made a new app and now got it working. Will the savurl method make me able to check individual files for changes in revision number? From what I’m able to read, it’s only files that resides in one’s own DB folder that can have rev listed in its metadata, not files that are shared via link?
Again, thanks!
Again, thanks!
Greg-DB
4 years agoDropbox Staff
The saveUrl method just allows you to save a file from a URL to the connected Dropbox account. That URL can be a Dropbox shared link, and in that case it will just save the latest version of the linked file; there isn't a way to specify a different revision.
As for the metadata, you can only get the list of revisions for files in the connected account (via listRevisions), not for files from shared links. You can use getSharedLinkMetadata to get the metadata for the linked file, which includes the current 'rev' value, but not previous values.
- PerOstergren4 years agoExplorer | Level 4
If I query with listFolder, get a response back and
print(response as Any)
, the folder content prints as a list of items as follows including rev, hash and id:
{ ".tag" = file; "client_modified" = "2014-06-05T05:22:59Z"; "content_hash" = 711560a047ed6607d41f328872246db9277d564aa400ee643c142871f8b48154; id = "id:n4ABlnhYTMcXXAAAAXXkg"; "is_downloadable" = 1; name = "Photo 2014-06-04 19 33 53.jpg"; "path_display" = "/Public/Photo 2014-06-04 19 33 53.jpg"; "path_lower" = "/public/photo 2014-06-04 19 33 53.jpg"; rev = 1e8a00562e0e; "server_modified" = "2014-06-05T05:23:59Z"; size = 2010202; }
However, if I separarate the entries from the result
for entry in result.entries { }
, I can't access the rev-value as it isnt listed anymore. Should I not use the response.entries method and instead try to parse the response on my own? Using getSharedLinkMetadata produces a result with more items, but no rev. The url used is for the shared folder, not a specific file.
- Greg-DB4 years agoDropbox Staff
To access FileMetadata.rev, you need to first cast Metadata to FileMetadata. There's an example of doing so here.
The getSharedLinkMetadata method will only return the metadata for the linked item. If you supply the link for the folder itself, you'll only get the metadata for the folder, which doesn't have a rev. You'd need to supply the link to the file to get the file's metadata.
About Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.
5,887 PostsLatest Activity: 2 hours agoIf 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 or Facebook.
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!