Creating an Asset

Assets can be created through the UI here. On this page, you will see two tabs; one to view assets that have already been uploaded, and another tab to upload new assets.

Alternatively, you can upload assets using our CLI or our API. (Note this is currently an experimental route).

# You can use the One Codex CLI to upload your assets.
# You will need to login first
onecodex --api-key $ONE_CODEX_API_KEY login

# Then begin your upload
onecodex assets upload $filename
# Start the upload

curl -u $ONE_CODEX_API_KEY: \
  -X POST -H "Content-Type: application/json" \
  https://app.onecodex.com/api/v1_experimental/assets/init_multipart_upload \
  -d @- << EOF 
{
  "filename": $filename
}
EOF

# This should return a response with the following JSON body:
#{
#		"callback_url": "/api/v1_experimental/assets/confirm_multipart_upload", 
#		"file_id": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
#		"s3_bucket": "onecodex-multipart-uploads-encrypted", 
#		"upload_aws_access_key_id": "XXXXXXXXXXXXXXXXXXXX",
#		"upload_aws_secret_access_key": "YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY"
#}

# You can then upload your file to our AWS bucket
AWS_ACCESS_KEY_ID=$upload_aws_access_key_id \
AWS_SECRET_ACCESS_KEY=$upload_aws_secret_access_key \
aws s3 cp $filename \
"s3://onecodex-multipart-uploads-encrypted/$file_id" --sse

# Once the upload has completed, you will need to confirm it
curl -u $ONE_CODEX_API_KEY: \
     -X POST -H "Content-Type: application/json" \
     "https://app.onecodex.com/api/v1_experimental/assets/confirm_multipart_upload" \
     -d @- << EOF
{
    "s3_path": "s3://onecodex-multipart-uploads-encrypted/$file_id",
    "filename": $filename,
    "name": "<an optional name for your asset>"
}
EOF

What’s Next