Main content

Files | Discussion Wiki | Discussion | Discussion
default Loading...

Examples

Menu

Loading wiki pages...

View
Wiki Version:
@[toc](Examples) File upload === Once you have an upload URL from a folder endpoint, you can upload a text file like this using curl: ``` curl -X "PUT" "https://test-files.osf.io/v1/resources/<guid>/providers/osfstorage/?name=sample.txt" \ -H "Authorization: Basic Thisisnotarealauthtoken" \ -H "Content-Type: text/plain" \ -d "This is a text file" ``` Change your authorization to the appropriate method for your application, replace the URL with a real URL and the auth token with a real auth token. Token auth ==== To us a Personal Access Token, make an `Authorization` header with the contents `Bearer thisisnotarealtoken`. In the curl example above, that would be: ``` curl -X "PUT" "https://test-files.osf.io/v1/resources/<guid>/providers/osfstorage/?name=sample.txt" \ -H "Authorization: Bearer Thisisnotarealauthtoken" \ -H "Content-Type: text/plain" \ -d "This is a text file" ``` To make a Personal Access Token, go to the relevant [OSF settings page](https://osf.io/settings/tokens/) and create one. You can limit the scope of the token, but remember that it has access to all of the information that you do within the limits of the scope, so be careful with your tokens. Complex node and file counts ==== I had to make a [script to count how many nodes were tagged with certain tags, and then count how many of those nodes had more than one file stored in their OSF Storage provider](https://osf.io/3egfe/). It takes some shortcuts on the counting (it doesn't check for folders vs files and it certainly doesn't go into hierarchy), but it's a good example of pulling things out of **pagination** and doing requests based on **related views**. It also has some code in it to handle **throttled** responses properly.
OSF does not support the use of Internet Explorer. For optimal performance, please switch to another browser.
Accept
This website relies on cookies to help provide a better user experience. By clicking Accept or continuing to use the site, you agree. For more information, see our Privacy Policy and information on cookie use.
Accept
×

Start managing your projects on the OSF today.

Free and easy to use, the Open Science Framework supports the entire research lifecycle: planning, execution, reporting, archiving, and discovery.