Share files publicly
Make a bucket public, so anyone with a file’s address can open it, such as images on your website.
Files are private by default. Make a bucket public when its files are meant for anyone: product photos, logos, documents you link to from your website. Every file in a public bucket gets a permanent address.
Make a bucket public
In the console, open the bucket’s Settings, turn on Public access, and confirm. Or send its visibility:
curl -X PATCH "$STORAGE_URL/buckets/photos" \
-H "Authorization: Bearer $STORAGE_API_KEY" \
-H "Content-Type: application/json" \
-d '{"visibility": "public"}'This needs Storage buckets: Edit. The answer holds the bucket’s publicUrl, the start of every file’s address in it:
{
"name": "photos",
"visibility": "public",
"publicUrl": "https://files.digitospace.com/k3m9q2x7v1c8r4t6w0z5/"
}A file’s address
A file’s address is the bucket’s publicUrl followed by its key, with each part of the key encoded for a URL. Files in a public bucket also carry their own publicUrl:
GET https://files.digitospace.com/k3m9q2x7v1c8r4t6w0z5/products/red%20shoes.jpgIn the console, Copy link on a file in a public bucket copies its address.
The address stays the same when you replace the file, so you can link to it from your website or app. It stops working when you delete the file or make the bucket private.
How public files are served
- Caching: files are served from Cloudflare’s network close to your visitors, and cached for up to a minute. A replaced or deleted file, or a bucket you make private, can take that long to update everywhere.
- Browsers: web pages, SVG images, and XML files are downloaded instead of shown, so a file in your bucket can never run in a visitor’s browser as if it were a website.
- Other websites: any website can load your public files, such as images and fonts.
- Large files: range requests are supported, so video and audio can be streamed and downloads can resume.
Make a bucket private again
Turn off Public access, or send {"visibility": "private"}. Its files stop being reachable at their public addresses within a minute. If you make it public again later, it gets the same addresses back.
Files we take down
We take down files that break our terms, such as phishing pages, malware, or files that are not yours to share. A taken down file answers 451 at its public address, and download links and copies of it are refused with taken_down. The console marks it, and you can still delete it. We can take down a whole bucket when the problem is wider.
To report a file, or if you think we made a mistake, write to abuse@digitospace.com. See Report abuse.
Last updated