Using presigned URLs
Introduction
Creating presigned URLs for Storj - HTTP POST & GET to a URL
All objects and paths are private and encrypted by default. However, it is possible to use a pre-signed URL via our S3-compatible gateway to enable unauthenticated customers/users to upload objects to buckets or access objects in buckets without providing an Access Grants or Getting started.
HTTP GET vs Storj Linkshare Service
While we support this behavior via the S3-compatible pre-signed URL function, as an alternative to sharing with a customer/user via a GET, consider utilizing our Linksharing Service. One advantage of this approach is the ability to easily create perpetual share links, valid until you remove them or until a configurable end date of any duration. You can even host a static website via Linkshare.
Tutorial
The goal of the following tutorial is to guide you in the creation of pre-signed URLs for Storj using a Python script and our multi-tenant hosted gateway.
Our lab example took place on MacOSX and used BREW as a package manager. Depending on your host operating system, you will need to use the appropriate package manager to fetch the prerequisites listed below.
Our implementation of the S3 standard allows additional configuration options. Please reference the official AWS S3 User Guide for additional details.
Prerequisites
Script
Create your script my_put_script.py
This script will create a “put” pre-signed URL to be used for uploading
Below you can see we need to set the following parameters:
ACCESS_KEY - S3 Credential created with Access
SECRET_KEY - S3 Credential created with Access
URL - You can use us1, eu1, or ap1 depending on location
BUCKET NAME - Name of the bucket related to this URL
url - Use ‘put_object to upload and ‘get_object’ to download/share
Key - Path of the object you wish to upload
ExpiresIn - How long the URL will be valid from its creation (in seconds)
Execute script myscript.py
The output of this script will be your pre-signed URL
Upload with URL and Curl
Set for file name and extension and paste in your newly generated pre-signed URL. Note that the pre-signed URL below is invalid and included as an example only.