Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

public download link for files #8256

Open
cdancette opened this issue Mar 30, 2018 · 10 comments
Open

public download link for files #8256

cdancette opened this issue Mar 30, 2018 · 10 comments

Comments

@cdancette
Copy link

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).

@felliott
Copy link
Member

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

@cdancette
Copy link
Author

cdancette commented Mar 30, 2018

@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
Copy link
Author

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

Thanks very much

@cdancette
Copy link
Author

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)

@BRosenblatt
Copy link

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.

@cdancette
Copy link
Author

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

@BRosenblatt
Copy link

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.

@danieldeidda
Copy link

hi adding download after the url only downloads the html page

@tgholipour
Copy link

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)

@benstear
Copy link

benstear commented Oct 30, 2023

hi adding download after the url only downloads the html page

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants