Download public shared folder
Hi,
I intent to download the naip files via this link. The problem is that the folder is too large and there seems no simple to download them.
I have read this post and this .
I am following the the following suggestions:
"
The general flow is this:
- Call the `GET /shared_items` endpoint to resolve the shared link to a folder with the BoxApi header
- Make whatever calls against the folder using the ID you get back from Step 1 (in your case, lots of `GET /folders/ID/items` and subsequent `GET /files/ID/content` calls) with the BoxApi header
"
For the first step, things went ok. I got the items ID of the folder and the sub-foldes, down to the .zip files information with cURL, like this:
curl https://api.box.com/2.0/folders/10***phone number removed for privacy***/items \
-H "Authorization: Bearer myTOKEN" \
-H "BoxApi: shared_link=https://nrcs.app.box.com/v/naip"
I get:
{"total_count":67,"entries":[{"type":"file","id":"611074755770","file_version":{"type":"file_version","id":"64***phone number removed for privacy***","sha1":"8be00cb814d9cb8cb01624c08d7f69fc2b5ef6df"},"sequence_id":"0","etag":"0","sha1":"8be00cb814d9cb8cb01624c08d7f69fc2b5ef6df","name":"ortho_1-1_hc_s_al001_2019_1.zip"},
...
For the second step, the suggested method as this link won't work. I got 404 "could not find the specified resource" I tried several ways, such as:
curl https://api.box.com/2.0/files/611074755770/content \
-H "Authorization: Bearer myTOKEN" \
-H "BoxApi: shared_link=https://nrcs.app.box.com/v/naip"
I do not know if there is a problem to download the files in a sub-folder with the shared link. Another question is that, if I obtained all the file ID, how could I download them simultaneously? I am thinking generating a .txt file with the step 2 codes with the various file ID. But not sure if this will work.
Thank you in advance for any suggestions!
-
Hi ,
Typically a 404 error when trying to access files like you are is caused when the access token being used is not scoped for the account that owns / can access the content, such as a service account (the app account for a JWT app) accessing files for another user when the access token is trying to look into its own account. Ideally you'll want to run the download request using an access token that has permission to download the file.
If the access token is valid, then it could be a permission issue. With shared links if the account that you're downloading from only has Previewer, Uploader, or Previewer-Uploader as their permission to the shared file, they won't be able to download the file.
So, check if the access token is valid and that the permissions to those files / folders are set to an appropriate level to download the content.
Please sign in to leave a comment.
Comments
1 comment