th object-storage

Create buckets, copy and sync files with th:// paths, make folders public, and share single files with links that expire.

About

Object Storage keeps files (objects) in buckets. Objects are private unless you make a folder public. In th, an object is written th://BUCKET/KEY; anything else is a path on your computer. A key ending in / is a folder (prefix).

PathMeans
th://mediaThe bucket media
th://media/photos/The folder photos/ in it
th://media/photos/cat.jpgOne object
./photos, C:\dataFiles on your computer
-Standard output (as the destination of cp)

The file commands use an Object Storage access key: a short-lived one made for you when you are signed in, or the one in TH_OBJECT_STORAGE_KEY_ID / TH_OBJECT_STORAGE_SECRET. Files over 64 MiB are uploaded in parallel parts. See also How Object Storage works.

How-to guides

Copy a folder to a bucket

Shell
th object-storage buckets create my-bucket
th object-storage cp -r ./backups th://my-bucket/backups
th object-storage ls th://my-bucket/backups/

With -r, the contents of ./backups go under backups/. Copy the other way (th://… ./dir) to download.

Keep a folder in sync

  1. Preview what would change: th object-storage sync ./public th://my-bucket/site --dry-run.
  2. Upload new and changed files: run it again without --dry-run. A file is unchanged when its size and MD5 match the object.
  3. Add --delete to also remove objects that are no longer in the folder (after a prompt).
Shell
th object-storage sync ./public th://my-bucket/site --delete

Make a folder public

Shell
th object-storage buckets public my-bucket --prefix images/
th object-storage buckets public my-bucket

Anyone can then open files under images/ without a key. Without parameters the command prints the current rules; --private --prefix images/ makes the folder private again.

Reads of public files are billed to your Project. Keep personal data out of public folders.

Commands

CommandDescription
th object-storage buckets createCreates a bucket.
th object-storage buckets listLists the Project's Object Storage buckets.
th object-storage buckets publicShows or changes what anyone may read from the bucket without a key.
th object-storage buckets deleteDeletes an empty bucket.
th object-storage lsWithout an argument lists the Project's buckets.
th object-storage cpCopies files to, from or between buckets.
th object-storage mvMoves files to, from or between buckets.
th object-storage syncUploads the files of LOCAL_DIR that are new or changed under PREFIX/.
th object-storage catWrites an object to standard output.
th object-storage statShows an object's size, type, ETag, digest and metadata.
th object-storage signPrints a link that downloads (GET) or uploads (PUT) the object without a key until it expires (at most 7d).
th object-storage rmDeletes an object.

th object-storage buckets create

Creates a bucket.

Syntax

Shell
th object-storage buckets create NAME [--region REGION]

NAME is 3-63 characters of a-z, 0-9, dots and hyphens. The region defaults to the configured one (th config set region) when it offers Object Storage, or to the only region that does.

Examples

Create a bucket in the default region

Shell
th object-storage buckets create my-bucket

In a specific region

Shell
th object-storage buckets create my-bucket --region bkk

Positional arguments

NameDescription
NAMERequiredThe bucket name: 3–63 characters of a-z, 0-9, dots and hyphens.

Global parameters

This command also takes the global parameters: --project, --region, --endpoint, --format, --quiet.

Back to top ↑

th object-storage buckets list

Lists the Project's Object Storage buckets.

Syntax

Shell
th object-storage buckets list

Examples

List buckets

Shell
th object-storage buckets list

Global parameters

This command also takes the global parameters: --project, --region, --endpoint, --format, --quiet.

Back to top ↑

th object-storage buckets public

Shows or changes what anyone may read from the bucket without a key.

Syntax

Shell
th object-storage buckets public NAME [--prefix P [--list]] [--private]
--prefix P          make the folder P (e.g. images/) public; --prefix ""
                    makes the whole bucket public
--prefix P --list   also let anyone list that folder
--private --prefix P  make that folder private again
--private           make the whole bucket private (removes every rule)

Without flags it prints the current rules.

Examples

Print the public rules

Shell
th object-storage buckets public my-bucket

Make images/ public

Shell
th object-storage buckets public my-bucket --prefix images/

Also let anyone list images/

Shell
th object-storage buckets public my-bucket --prefix images/ --list

Make the whole bucket private

Shell
th object-storage buckets public my-bucket --private

Positional arguments

NameDescription
NAMERequiredThe bucket name: 3–63 characters of a-z, 0-9, dots and hyphens.

Parameters

NameTypeDefaultDescription
--prefixstringFolder (key prefix) the change applies to
--listflagAlso allow listing the public folder
--privateflagRemove the rule for --prefix, or all rules

Global parameters

This command also takes the global parameters: --project, --region, --endpoint, --format, --quiet.

Back to top ↑

th object-storage buckets delete

Deletes an empty bucket.

Syntax

Shell
th object-storage buckets delete NAME [--force] [--quiet]

With --force a bucket with objects is deleted at once and its objects are removed in the background. --quiet skips the prompt.

Examples

Delete an empty bucket

Shell
th object-storage buckets delete my-bucket

Delete it with all its objects, no prompt

Shell
th object-storage buckets delete my-bucket --force --quiet

Positional arguments

NameDescription
NAMERequiredThe bucket name: 3–63 characters of a-z, 0-9, dots and hyphens.

Parameters

NameTypeDefaultDescription
--forceflagDelete the bucket with all its objects

Global parameters

This command also takes the global parameters: --project, --region, --endpoint, --format, --quiet.

Back to top ↑

th object-storage ls

Without an argument lists the Project's buckets.

Syntax

Shell
th object-storage ls [th://BUCKET[/PREFIX]] [--recursive]

With th://BUCKET lists the objects and folders at the top of the bucket, with th://BUCKET/PREFIX those under PREFIX. --recursive lists every object below, without folders.

Examples

List buckets

Shell
th object-storage ls

Objects and folders under reports/

Shell
th object-storage ls th://my-bucket/reports/

Every object in the bucket

Shell
th object-storage ls th://my-bucket --recursive

Positional arguments

NameDescription
th://BUCKET[/PREFIX]OptionalA bucket, optionally with a folder (prefix) in it.

Parameters

NameTypeDefaultDescription
--recursiveflagList every object under the prefix
-rflagSame as --recursive

Global parameters

This command also takes the global parameters: --project, --region, --endpoint, --format, --quiet.

Back to top ↑

th object-storage cp

Copies files to, from or between buckets.

Syntax

Shell
th object-storage cp SRC DST [-r] [--content-type TYPE]

Objects are th://BUCKET/KEY; anything else is a local path ("-" as DST writes to stdout).

th object-storage cp photo.jpg th://media/photos/      -> photos/photo.jpg
th object-storage cp th://media/a.pdf ./                -> ./a.pdf
th object-storage cp th://media/a.pdf th://archive/a.pdf (copied inside Object Storage)

With -r, SRC is a folder (or a prefix) and its contents go under DST, like aws s3 cp --recursive. Files over 64 MiB are uploaded in parallel parts. The content type is guessed from the file extension unless given.

Examples

Upload a file into a folder

Shell
th object-storage cp ./report.pdf th://my-bucket/reports/

Upload a folder

Shell
th object-storage cp -r ./backups th://my-bucket/backups

Download a file

Shell
th object-storage cp th://my-bucket/reports/report.pdf ./

Write an object to standard output

Shell
th object-storage cp th://my-bucket/data.json - | jq .

Positional arguments

NameDescription
SRCRequiredWhat to copy: a local path or th://BUCKET/KEY (a folder or prefix with -r).
DSTRequiredWhere to copy it: a local path, th://BUCKET/KEY or th://BUCKET/FOLDER/, or - for standard output.

Parameters

NameTypeDefaultDescription
--recursiveflagCopy a folder or prefix and everything under it
-rflagSame as --recursive
--content-typestringby extensionContent type of uploaded objects

Global parameters

This command also takes the global parameters: --project, --region, --endpoint, --format, --quiet.

Back to top ↑

th object-storage mv

Moves files to, from or between buckets.

Syntax

Shell
th object-storage mv SRC DST [-r] [--content-type TYPE]

Objects are th://BUCKET/KEY; anything else is a local path ("-" as DST writes to stdout).

th object-storage mv photo.jpg th://media/photos/      -> photos/photo.jpg
th object-storage mv th://media/a.pdf ./                -> ./a.pdf
th object-storage mv th://media/a.pdf th://archive/a.pdf (copied inside Object Storage)

With -r, SRC is a folder (or a prefix) and its contents go under DST, like aws s3 cp --recursive. Files over 64 MiB are uploaded in parallel parts. The content type is guessed from the file extension unless given.

Examples

Move an object to another folder

Shell
th object-storage mv th://my-bucket/inbox/a.pdf th://my-bucket/done/

Positional arguments

NameDescription
SRCRequiredWhat to copy: a local path or th://BUCKET/KEY (a folder or prefix with -r).
DSTRequiredWhere to copy it: a local path, th://BUCKET/KEY or th://BUCKET/FOLDER/, or - for standard output.

Parameters

NameTypeDefaultDescription
--recursiveflagCopy a folder or prefix and everything under it
-rflagSame as --recursive
--content-typestringby extensionContent type of uploaded objects

Global parameters

This command also takes the global parameters: --project, --region, --endpoint, --format, --quiet.

Back to top ↑

th object-storage sync

Uploads the files of LOCAL_DIR that are new or changed under PREFIX/.

Syntax

Shell
th object-storage sync LOCAL_DIR th://BUCKET[/PREFIX] [--delete] [--dry-run]

A file is unchanged when its size matches and its MD5 matches the object's ETag (objects uploaded in parts have no MD5 ETag: then a local file newer than the object counts as changed). --delete also deletes objects under PREFIX/ that are no longer in LOCAL_DIR (after a prompt --quiet skips).

Examples

Show what would change

Shell
th object-storage sync ./public th://my-bucket/site --dry-run

Upload changes and remove deleted files

Shell
th object-storage sync ./public th://my-bucket/site --delete

Positional arguments

NameDescription
LOCAL_DIRRequiredThe folder on your computer to upload.
th://BUCKET[/PREFIX]RequiredA bucket, optionally with a folder (prefix) in it.

Parameters

NameTypeDefaultDescription
--deleteflagDelete objects that are not in LOCAL_DIR
--dry-runflagOnly print what would change
--content-typestringby extensionContent type of uploaded objects

Global parameters

This command also takes the global parameters: --project, --region, --endpoint, --format, --quiet.

Back to top ↑

th object-storage cat

Writes an object to standard output.

Syntax

Shell
th object-storage cat th://BUCKET/KEY

Examples

Print an object

Shell
th object-storage cat th://my-bucket/config.json

Positional arguments

NameDescription
th://BUCKET/KEYRequiredAn object, such as th://media/photos/cat.jpg (a prefix with -r).

Global parameters

This command also takes the global parameters: --project, --region, --endpoint, --format, --quiet.

Back to top ↑

th object-storage stat

Shows an object's size, type, ETag, digest and metadata.

Syntax

Shell
th object-storage stat th://BUCKET/KEY

Examples

Size, type, ETag and metadata

Shell
th object-storage stat th://my-bucket/reports/report.pdf

Positional arguments

NameDescription
th://BUCKET/KEYRequiredAn object, such as th://media/photos/cat.jpg (a prefix with -r).

Global parameters

This command also takes the global parameters: --project, --region, --endpoint, --format, --quiet.

Back to top ↑

th object-storage sign

Prints a link that downloads (GET) or uploads (PUT) the object without a key until it expires (at most 7d).

Syntax

Shell
th object-storage sign th://BUCKET/KEY [--expires 1h] [--method GET|PUT]

Examples

A download link for one hour

Shell
th object-storage sign th://my-bucket/reports/report.pdf --expires 1h

An upload link for 15 minutes

Shell
th object-storage sign th://my-bucket/uploads/photo.jpg --method PUT --expires 15m

Positional arguments

NameDescription
th://BUCKET/KEYRequiredAn object, such as th://media/photos/cat.jpg (a prefix with -r).

Parameters

NameTypeDefaultDescription
--expiresstring1hHow long the link works: 15m, 1h, 7d (default 1h)
--methodstringGETGET (download, default) or PUT (upload)

Global parameters

This command also takes the global parameters: --project, --region, --endpoint, --format, --quiet.

Back to top ↑

th object-storage rm

Deletes an object.

Syntax

Shell
th object-storage rm th://BUCKET/KEY [-r] [--quiet]

With -r deletes every object under the prefix (after a prompt that --quiet skips).

Examples

Delete one object

Shell
th object-storage rm th://my-bucket/tmp/old.log

Delete everything under tmp/, no prompt

Shell
th object-storage rm -r th://my-bucket/tmp/ --quiet

Positional arguments

NameDescription
th://BUCKET/KEYRequiredAn object, such as th://media/photos/cat.jpg (a prefix with -r).

Parameters

NameTypeDefaultDescription
--recursiveflagDelete everything under the prefix
-rflagSame as --recursive

Global parameters

This command also takes the global parameters: --project, --region, --endpoint, --format, --quiet.

Back to top ↑