osf.io
osf.io copied to clipboard
public download link for files
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).
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 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)
I just found how to do it, by making the project public (button on the project page), it works !
Thanks very much
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)
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.
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
Great, thank you!
Follow these instructions using "RPP: Analysis" (https://osf.io/ytpuq/) as the example project.
- Go to the API endpoint for the project:
GET https://api.osf.io/v2/nodes/ytpuq/
- Follow the
files
relationship (data.relationships.files.links.related.href
):GET https://api.osf.io/v2/nodes/ytpuq/files/
- 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/
- 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 calledAnalysis Audit.zip
. This only works for folder urls served fromfiles.osf.io
. You can do this for subfolders by traversing thefiles
relationship in the API until you arrive at your desired folder.
hi adding download after the url only downloads the html page
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)
hi adding download after the url only downloads the html page
@danieldeidda any luck with this? I am having the same problem.
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