You can run the presign command to generate a signed URL.
Command syntax
ossutil presign oss://bucket[/prefix] [flags]
Parameter | Type | Description |
-d, --dirs | / | Specifies that the objects and subdirectories in the current directory are returned. |
--encoding-type | string | The encoding method used to encode the object name. Valid value: url. |
--end-with | string | Specifies that objects whose names are alphabetically before or the same as the value of the --end-with parameter are returned. |
--exclude | stringArray | The exclusion rule for paths or object names. |
--exclude-from | stringArray | Specifies that the exclusion rule is read from the rules file. |
--expires-date | Time | The point in time at which the signed URL expires. |
--expires-duration | Duration | The validity period of the signed URL. The validity period ranges from 1 second to 1 week. Default value: 15m0s. |
--files-from | stringArray | Specifies that the object names are read from the rules file, and empty lines or comment lines are ignored. |
--files-from-raw | stringArray | Specifies that the object names are read from the rules file. |
--filter | stringArray | The filter rule for the paths or object names. |
--filter-from | stringArray | Specifies that the filter rule for the paths or object names is read from the rules file. |
-f, --force | / | Specifies that the command is forcibly run without a prompt for confirmation. |
--include | stringArray | The inclusion rule for paths or object names. |
--include-from | stringArray | Specifies that the inclusion rule is read from the rules file. |
--limited-num | int | The maximum number of results to return. |
--list-objects | / | Specifies that the ListObjects operation is called to list objects. |
--max-age | Duration | Specifies that the objects whose last modified time is earlier than the value of the --max-age parameter are excluded. The default unit is seconds. The unit can be milliseconds, seconds, minutes, hours, days, weeks, months, or years. By default, this parameter is left empty. |
--max-mtime | Time | Specifies that the objects whose last modified time is later than the value of the --max-mtime parameter are excluded. The value is in UTC. By default, this parameter is left empty. |
--max-size | SizeSuffix | The maximum size of the object that can be transferred. The default unit is bytes. The unit of object size can be bytes, KiB, MiB, GiB, TiB, or PiB. Note: 1 KiB = 1024 bytes. |
--metadata-exclude | stringArray | The exclusion rule for object metadata. |
--metadata-filter | stringArray | The filter rule for object metadata. |
--metadata-filter-from | stringArray | Specifies that the filter rule for object metadata is read from the rules file. |
--metadata-include | stringArray | The inclusion rule for object metadata. |
--min-age | Duration | Specifies that the objects whose last modified time is later than the value of the --min-age parameter are excluded. The default unit is seconds. The unit can be milliseconds, seconds, minutes, hours, days, weeks, months, or years. By default, this parameter is left empty. |
--min-mtime | Time | Specifies that the objects whose last modified time is earlier than the value of the --min-mtime parameter are excluded. The value is in UTC. By default, this parameter is left empty. |
--min-size | SizeSuffix | The minimum size of the object that can be transferred. The default unit is bytes. The unit of object size can be bytes, KiB, MiB, GiB, TiB, or PiB. Note: 1 KiB = 1024 bytes. |
--page-size | int | The maximum number of objects that can be returned. Default value: 1000. Valid values: 1 to 1000. |
--query-param | stringArray | The query parameters in the request. |
-r, --recursive | / | Specifies that the command is recursively run on objects. If this parameter is specified, the command takes effect on all objects that meet the conditions in the bucket. Otherwise, the command takes effect on only the objects in the specified path. |
--request-payer | string | The payer of the request. If pay-by-requester is enabled for the bucket, set this parameter to requester. |
--start-after | string | Specifies that objects whose names are alphabetically before or the same as the value of the --end-with parameter are returned. |
--traffic-limit | int | The bandwidth limit of a single connection. Valid values: 819200 to 838860800. |
--version-id | string | The version ID of the object. |
For more information, see Command-line options.
Examples
For the example.txt object in the examplebucket bucket, generate a signed URL that has the default validity period of 15 minutes.
ossutil presign oss://examplebucket/example.txt
For the example.txt object in the examplebucket bucket, generate a signed URL that has a validity period of 1 hour.
ossutil presign oss://examplebucket/example.txt --expires-duration 1h
For the example.txt object in the examplebucket bucket, generate a signed URL that remains valid until 2024-06-01T12:00:00 (UTC).
ossutil presign oss://examplebucket/example.txt --expires-date 2024-06-01T12:00:00
For the example.txt object in the examplebucket bucket, generate a signed URL that contains image processing parameters.
ossutil presign oss://examplebucket/example.txt --query-param x-oss-process=image/resize,m_fixed,w_100,h_100/rotate,90
Generate a singed URL for the "123" version of the example.txt object in the examplebucket bucket.
ossutil presign oss://examplebucket/example.txt --version-id 123
For objects in the "folder" directory in the examplebucket bucket, generate signed URLs that have a validity period of 15 minutes.
ossutil presign oss://examplebucket/folder/ -r
For TXT objects in the "folder" directory of the examplebucket bucket, generate URLs that have the default validity period of 15 minutes.
ossutil presign oss://examplebucket/folder/ -r --include "*.txt"