cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Organizing your research is important to easily review and share it. Learn how Kim uses Dropbox to gather and organize her research 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: 
1
Ask
2
Reply and help

Programmatically Process Shared Link Folders and Sub-Folders and Their Contents

Re: Programmatically Process Shared Link Folders and Sub-Folders and Their Contents

eliotcole
Explorer | Level 4

Ello, I'm back again! 🙂

 

I'm still trying to make this work.

 

I'm working with the copy, now.

 

So, let's say that I have this shared folder:

 

https://www.dropbox.com/sh/g0ja3gk1u1pjf9y/AADjilHpLqi-e5PO-RGp4PHIa?dl=0

 

That shared folder has a subfolder called:

 

test5

If I would like to copy the contents of that test5 subfolder to a given folder in the API, what am I putting in the 'from_path' field in this JSON?

 

 

{
    "from_path": "WHATGOESHERE?",
    "to_path": "/destination5",
    "allow_shared_folder": true,
    "autorename": false,
    "allow_ownership_transfer": false
}

 

 

 

 

------

 

 

Here's a few attempts that I've made that have failed miserably:

Spoiler

1.

{
    "from_path": "https://www.dropbox.com/sh/g0ja3gk1u1pjf9y/AADjilHpLqi-e5PO-RGp4PHIa/test5",
    "to_path": "/destination5",
    "allow_shared_folder": true,
    "autorename": false,
    "allow_ownership_transfer": false
}

2.

 

{
    "shared_link": { "url": "https://www.dropbox.com/sh/g0ja3gk1u1pjf9y/AADjilHpLqi-e5PO-RGp4PHIa" },
    "from_path": "/test5",
    "to_path": "/destination5",
    "allow_shared_folder": true,
    "autorename": false,
    "allow_ownership_transfer": false
}

3.

 

 

{
  "from_path": {
    "shared_link": {
      "url": "https://www.dropbox.com/sh/g0ja3gk1u1pjf9y/AADjilHpLqi-e5PO-RGp4PHIa"
    },
    "path": "/test5"
  },
  "to_path": "/destination5",
  "allow_shared_folder": true,
  "autorename": false,
  "allow_ownership_transfer": false
}

 

I've also tried to have a look at the JAVA SDK builder, as I think that you actually recommended that someone was able to do it with that ... but I really don't understand how to use that.

Re: Programmatically Process Shared Link Folders and Sub-Folders and Their Contents

Greg-DB
Dropboxer

Unfortunately, the Dropbox API doesn't offer a way to copy from a shared link into the connected Dropbox account via the API like this, but I'll pass this along as a feature request as well. I can't promise if/when that might be implemented though. 

 

The /2/files/copy_v2 call (or native method in an SDK) that you're referring to only supports copying files from one location in the connected account to another location in the same account. It doesn't support using a shared link as the source. 

 

You could download the files, using /2/sharing/get_shared_link_file, and then upload them to the account, e.g., using /2/files/upload, but that would be comparatively inefficient of course.

Re: Programmatically Process Shared Link Folders and Sub-Folders and Their Contents

eliotcole
Explorer | Level 4

Cheers, Greg, and thanks for taking it to the developers.

 

I will say that I've perused a few topics on this, and they've all been at least a year old, so I'm wondering if there's ever actually going to be any real movement with the (Public) Shared Folders/Links. (i'm not saying that in a tone that would indicate an attack on your person, mate ... just ... it seems like it's something that isn't desired for the public to have)

 

I guess, then, my final question would be what API command would you see as the best use case with regards to a cloud based implementation that may have size limits (let's take the Google API with limits size to 50MB per upload/download).

 

 

I would imagine that a "download then upload" won't be the ideal solution for that, would it? Would something like " get_temporary_link " work better. So it would:

  1. Locate a file ID.
  2. Generate a temporary link.

Allow that link to be used to directly access the file in question?

 

To be clear, I'm not stating that in a literal fashion, just using the get_temporary_link as an example, I'm sure there's a more appropriate function to achieve this.

 

Essentially, once I have identified a file that I would like to copy to another (let's assume an external API to work this out better) then I need to essentially be given a direct link to the file, somehow, to present to the other API. How would I get that link?

 

 

----

Would it perhaps be " get_shared_link_file " ?

 

If so, how would that work with the previously mentioned subfolder issues in that path?

 

 

https://content.dropboxapi.com/2/sharing/get_shared_link_file

 

 

 

(I'm about to attempt it, but will try to play it out here, too)

Re: Programmatically Process Shared Link Folders and Sub-Folders and Their Contents

Greg-DB
Dropboxer

Right, whenever possible, it's best to avoid unnecessarily uploading/downloading locally, for the sake of reliability and efficiency. Passing a link between two services, if supported, would likely be faster.

 

In this case, if you need a direct link to a file hosted on Dropbox, the specifics will depend on if the file exists in the Dropbox account you're connected to via the API (i.e., the one for which you have an access token).

 

If the file is in the connected account, /2/files/get_temporary_link would be a good option. That gives you a direct link to the file content, that you could hand off to the other service. Note that these links only last for four hours.

 

If the file is not in the connected account though, and say, you just have a shared link, /2/files/get_temporary_link won't work. Instead, this will depend on the shared link you have. If the shared link is already for the file itself, you can modify it for direct access as covered here. However, if the shared link is just for a parent folder, as discussed through this thread, then unfortunately there isn't a good solution. As earlier, the API doesn't offer a way to get a link to just the nested file based on a shared link to the folder that contains it.

Re: Programmatically Process Shared Link Folders and Sub-Folders and Their Contents

eliotcole
Explorer | Level 4

Thanks again for coming back on this, mate. Really very much appreciated.

 

One last question ... how about the whole folder? That is, we know, not nested, and available at root.

 

Is there any internal reason given as to why the access to Shared Files is so antiquated (sorry) ... or ... let's be honest ... restrictive ... next to the rest of the interface? It seems ... odd. Particularly given the removal of RSS and the way that people use Shared Folders.

 

----

Also, not for nothing, but then this particular guide should include that Shared Sub-Folders are essentially not accessible via the API:

DBX File Access Guide - Dropbox (the "Non-downloadable files" section)

 

Re: Programmatically Process Shared Link Folders and Sub-Folders and Their Contents

Greg-DB
Dropboxer

Thanks for the feedback! I can't speak to why any particular feature was or wasn't implemented, but we appreciate you taking the time to share this. I'll send it along.

 

 

If you have a shared link for a folder and wish to get a direct link to that, you can likewise modify that as documented here. For folders, that will give you a .zip file of the folder.

Re: Programmatically Process Shared Link Folders and Sub-Folders and Their Contents

Greg-DB
Dropboxer

Update: The Dropbox API now returns the shared link for the nested item as 'url' when requesting the metadata for that item using the "path" parameter on /2/sharing/get_shared_link_metadata (instead of the original parent link).

Who's talking

Top contributors to this post

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