createSignedUrl
The createSignedUrl
method creates a temporary accessible URL for the object with the specified key.
async function createSignedUrl(
key: string,
expiry?: number
): Promise<string>;
Reference
Overview
You can create a temporarily accessible URL valid for 30 seconds for the object with the specified key by calling the createSignedUrl
method.
import { myStorage } from "#elements";
...
await myStorage.createSignedUrl("my-data/string.txt", 30);
...
Parameters
key
: A string that uniquely identifies the object. This string should start and end with letters or numbers, and the middle can contain letters, numbers, dots, slashes, hyphens, or underscores.expiry
: (optional) The duration of the temporary link in seconds, defaulting to 60 seconds.
Returns
The createSignedUrl
method returns a string that is a temporary access URL.
Caveats
- For security reasons, set the
expiry
value following the principle of least privilege.