osf.io icon indicating copy to clipboard operation
osf.io copied to clipboard

public download link for files

Open cdancette opened this issue 6 years ago • 11 comments

Hi, thanks for the great platform ! I was wondering if there was a way to get a public link for files uploaded on osf.io, I didn't find one (there's just a download button, but it doesn't give a link for a specific file / folder).

cdancette avatar Mar 30 '18 13:03 cdancette

Hey @cdancette,

Yes, there is! If you add /download to the end of the file url, that will work as a download link. e.g. https://osf.io/mst3k ==> https://osf.io/mst3k/download.

Cheers, @felliott

felliott avatar Mar 30 '18 14:03 felliott

@felliott Thanks for your answer !

Though that's not exactly what i'm looking for, it seems this work only if the user is logged in

$ curl https://osf.io/{id}/download -I
HTTP/1.1 302 FOUND
Location: https://accounts.osf.io/login?service=https://osf.io/{id}/download

Or is there a setting to allow this file to be public ? I'd like to download the file from a script (to make it easier to replicate the results)

cdancette avatar Mar 30 '18 14:03 cdancette

I just found how to do it, by making the project public (button on the project page), it works !

Thanks very much

cdancette avatar Mar 30 '18 14:03 cdancette

And I had another similar question, can we have the same link for a folder (to download it as a zip) ? I don't find the "id" of the folder (like we had for the file)

cdancette avatar Mar 30 '18 15:03 cdancette

Hi @cdancette! We don't currently assign folders short ids like we do with files. However, if you're comfortable working with our API, I can describe the roundabout way to do this. If not, I'll record your interest in this feature in our internal tracker to help inform future development.

BRosenblatt avatar Apr 04 '18 20:04 BRosenblatt

hi, i'd be glad to know how this would be done using the API ! for the feature, let me know if I can help develop it

cdancette avatar Apr 04 '18 22:04 cdancette

Great, thank you!

Follow these instructions using "RPP: Analysis" (https://osf.io/ytpuq/) as the example project.

  1. Go to the API endpoint for the project: GET https://api.osf.io/v2/nodes/ytpuq/
  2. Follow the files relationship (data.relationships.files.links.related.href): GET https://api.osf.io/v2/nodes/ytpuq/files/
  3. Follow the files relationship for the provider you want (data.relationships.files.links.related.href): GET https://api.osf.io/v2/nodes/ytpuq/files/osfstorage/
  4. Identify the folder you want to download. Let's assume "Analysis Audit" for this example. Take the link at links.upload and append the following query parameter: ?zip= GET. GET https://files.osf.io/v1/resources/ytpuq/providers/osfstorage/55d386c68c5e4a2d0b438d39/?zip= This will kick off a Download-as-Zip (DAZ) process, creating and downloading a file called Analysis Audit.zip. This only works for folder urls served from files.osf.io. You can do this for subfolders by traversing the files relationship in the API until you arrive at your desired folder.

BRosenblatt avatar Apr 09 '18 17:04 BRosenblatt

hi adding download after the url only downloads the html page

danieldeidda avatar Jul 26 '23 13:07 danieldeidda

I have trouble getting read-only OneDrive folders embedded in a public OSF project. Following the api trail leads to links for folders using curl -L -o 'test_folder.zip' 'https://files.osf.io/v1/resources/GUID/providers/onedrive/01SXXXX4EA' does not work. there are subfolders and files in this test_folder. I also tried adding ?zip= and ?dl=1 at the end, downloads a error message or bad zip file.

(also interested in answer if the shared OSF was private, but not as a project member)

tgholipour avatar Oct 19 '23 11:10 tgholipour

hi adding download after the url only downloads the html page

@danieldeidda any luck with this? I am having the same problem.

benstear avatar Oct 30 '23 23:10 benstear

The right approach is to use the download API via wget with --content-dispostion flag to preserve the original name.

For example:

wget --content-disposition https://osf.io/cwu4m/download

maciejskorski avatar Jul 29 '24 10:07 maciejskorski