Skip to main content

Get a link to an object

You can:

We do not recommend using Cyrillic in object names. If you use Cyrillic, encode the part of the link containing Cyrillic to work with links to such objects.

  1. In the control panel, on the top menu, click Products and select S3.
  2. Перейдите in раздел Бакеты.
  3. Откройте страницу бакета → вкладка Объекты.
  4. In the object line, click .
  5. In the link line, click .

You can:

You can get a temporary or permanent link to an object in a private bucket.

An object in a private bucket will be available via a link of the type https://<bucket_public_domain>/<object_name>, where:

Когда вы впервые создаете ссылку on объект in приватном бакете, in проекте автоматически создается публичный бакет links. Созданная ссылка добавляется in него in виде объекта with таким же именем, как у основного объекта. Объекты in бакете links имеют нулевой размер and не потребляют объем хранения. Если вы настроите ссылку как временную, объект со ссылкой автоматически удалится из бакета links, когда ссылка перестанет работать.

To create a link:

  1. In the control panel, on the top menu, click Products and select S3.

  2. Перейдите in раздел Бакеты.

  3. Откройте страницу бакета → вкладка Объекты.

  4. In the menu for the object, select Share.

  5. Optional: in the Link URL field, change the object name that will display in the link or leave the current one.

  6. Optional: to allow the link to be used only once, check the One-time link checkbox.

  7. Optional: to limit the link duration, check the Time limits checkbox and select one of the options:

    • Delete after — the link will stop working after the selected period of time after creation;
    • Delete at specified time — the link will stop working at the selected date and time.
  8. Click Create link.

  9. To copy the link, click . You will be able to copy it later in the links bucket.

С помощью подписанных URL (Presigned URLs) AWS SDK можно получить временную ссылку on объект. Подробнее in инструкции Sharing objects with presigned URLs документации AWS.

Script example:

import boto3

ACCESS_KEY = "<access_key>"
SECRET_KEY = "<secret_key>"
ENDPOINT_URL = "<s3_domain>"
BUCKET_NAME = "<bucket_name>"
OBJECT_KEY = "<path_to_object>"
EXPIRES_IN = "<time>"

s3 = boto3.client(
"s3",
aws_access_key_id=ACCESS_KEY,
aws_secret_access_key=SECRET_KEY,
endpoint_url=ENDPOINT_URL,
)

url = s3.generate_presigned_url(
ClientMethod="get_object",
Params={"Bucket": BUCKET_NAME, "Key": OBJECT_KEY},
ExpiresIn=EXPIRES_IN
)

print("\PresignedUrl
:")
print(url)

Specify:

  • <access_key> — the value of the Access key field from the S3 key;
  • <secret_key> — the value of the Secret key field from the S3 key;
  • <s3_domain> — the S3 API domain depending on the pool where the bucket is located;
  • <bucket_name> — the bucket name;
  • <path_to_object> — the path to the object in the bucket;
  • <time> — the link duration in seconds.

Script example:

import boto3

def get_public_url(bucket_uuid: str, object_key: str) -> str:

return f"https://{bucket_uuid}.selstorage.ru/{object_key}"

if __name__ == "<file_name>":
bucket_uuid = "<uuid>"
object_key = "<path_to_object>"
url = get_public_url(bucket_uuid, object_key)
print("Public URL:", url)

Specify:

  • <file_name> — the Python file name;
  • <uuid> — the unique bucket identifier, can be viewed in the bucket public domain;
  • <path_to_object> — the path to the object in the bucket.