---
title: "Presigned URL in S3 | Hostman Docs"
description: "Learn how to create presigned URLs in S3 via Hostman dashboard and AWS CLI, including examples for download, upload, and versioned objects."
---

> For the complete documentation index for AI agents, see [llms.txt](https://hostman.com/llms.txt).

A **Presigned URL** in S3 allows temporary access to an object in storage without the need to change the object's access permissions. It is a convenient tool for downloading files by third-party users. In this article, we will look at how to create a Presigned URL in two ways: in the Hostman dashboard or via AWS CLI.

## In the Hostman Dashboard

Presigned URL generation is only available for private buckets. To generate a Presigned URL:

1.  Go to the **S3 storage** section and click on the bucket.
2.  In the **Objects** tab, hover over the object and click the **File link** button.

![0a12ff53 9cb4 4b16 A2fa 1166627866cc](https://content.hostman.com/assets/c2a3524d-63ae-46e1-87b7-0b238cb687d4.png?width=1568&height=867)

The link will be copied to the clipboard and will remain active for 60 minutes. After that, the link will return a 403 error. The dashboard does not allow changing this parameter.

You can also generate a link for a specific object version if [versioning is enabled](https://hostman.com/docs/s3/supported-features/object-versioning/) on the bucket. To do this:

1.  Click the three dots next to the object and select **Version history**. 
2.  Click **File link** next to the desired version.

## Via AWS CLI

You can create a Presigned URL using AWS CLI with the following command:

```shell
aws s3 presign s3://<bucket>/<object> --expires-in 60 --endpoint-url https://s3.hmstorage.net
```

The `--expires-in` parameter is optional. It defines how long the object will be available via the link (in seconds). If the parameter is not specified, the object will be available for 3600 seconds (1 hour).

Standard utilities do not support generating a presigned URL for a version other than the current one. To create a link for a specific object version, you can use custom scripts. For example, the following Python script can be used:

```py
#!/usr/bin/env python3
import argparse
import boto3

parser = argparse.ArgumentParser()
parser.add_argument('--bucket', required=True)
parser.add_argument('--key', required=True)
parser.add_argument('--expires-in', type=int, default=3600)
parser.add_argument('--version-id')
parser.add_argument('--method', default='get_object')
args = parser.parse_args()

client = boto3.client('s3', endpoint_url='https://s3.hmstorage.net')
params = {'Bucket': args.bucket, 'Key': args.key}

if args.version_id:
    params.update({'VersionId': args.version_id})

url = client.generate_presigned_url(args.method, Params=params, ExpiresIn=args.expires_in)

print(url)
```

Run the script with:

```shell
python ./main.py --bucket <bucket-name> --key <object-key> --expires-in 6969 --version-id <object-version>
```

Where:

-   `--expires-in` is time in seconds until the link expires.
-   `--version-id` is the object version (`VersionId`), which can be obtained, for example, via AWS CLI.

The script will take authentication credentials from `~/.aws/credentials`.

### Generating a Presigned URL for Object Upload

You can pre-generate a presigned URL for uploading an object, even if the object does not yet exist in the bucket. Standard utilities like AWS CLI do not support this, but it can be done via an SDK, such as `boto3` for Python.

Example script:

```py
import boto3
from botocore.client import Config

# Enter your credentials
AWS_ACCESS_KEY_ID = 'S3 Access Key'
AWS_SECRET_ACCESS_KEY = 'S3 Secret Access Key'
BUCKET_NAME = 'Bucket Name'
OBJECT_KEY = 'example.txt'  # name of the future object
EXPIRES_IN = 3600  # link expiration time in seconds

s3 = boto3.client(
    's3',
    endpoint_url='https://s3.hmstorage.net',
    aws_access_key_id=AWS_ACCESS_KEY_ID,
    aws_secret_access_key=AWS_SECRET_ACCESS_KEY,
    config=Config(signature_version='s3v4'),
    region_name='us-2'
)

# Generate presigned URL
url = s3.generate_presigned_url(
    ClientMethod='put_object',
    Params={
        'Bucket': BUCKET_NAME,
        'Key': OBJECT_KEY,
    },
    ExpiresIn=EXPIRES_IN
)

print(url)
```

Note: You do not need to specify `Content-Type` when generating the link, as including it may cause an error.

After running the script, a temporary upload link will be generated.

You can upload the file using `curl`:

```shell
curl -X PUT -T /path/to/file.txt -H "Content-Type: text/plain" "<presigned-url-from-script>"
```
