Skip to main content

Get a reference to an object

Last update:

You can:

We do not recommend using Cyrillic characters in object names.If you use Cyrillic characters, encode the Cyrillic part of the reference to work with references to such objects.

  1. In the control panel, on the top menu, click Products and select S3.
  2. Go to the Buckets section.
  3. Open the baket page → Objects tab.
  4. On the line with the object, click.
  5. On 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 accessible by a link of the form https://<bucket_public_domain>/<object_name>, where:

When you first create a link to an object in a private bucket, a public links bucket is automatically created in the project. The created link is added to it as an object with the same name as the main object.Objects in the links bucket have zero size and do not consume storage space.If you configure a link as a temporary link, the object with the link will be automatically removed from the links bucket when the link stops working.

To create a link:

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

  2. Go to the Buckets section.

  3. Open the baket page → Objects tab.

  4. From themenu of the object, select Open Access.

  5. Optional: in the Link Address field, change the name of the object to be displayed in the link, or leave the current one.

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

  7. Optional: to limit the time the link is valid, check the Time Limits checkbox and select one of the options:

    • Delete via — link will stop working after the selected time interval after creation;
    • Delete at a specified time — the link will stop working on the selected date and time.
  8. Click Create Link.

  9. To copy a link, click. You can copy it later in the links package.

You can use AWS SDK Presigned URLs to get a temporary reference to an object.For more information, see Sharing objects with presigned URLs in the AWS documentation.

Sample script:

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> — field value Access key from S3 key;
  • <secret_key> — field value Secret key from S3 key;
  • <s3_domain> — S3 API domain depending on the pool in which the bucket is located;
  • <bucket_name> — bucket name;
  • <path_to_object> — path to the object in the baket;
  • <time> — link validity time in seconds.

Sample script:

import boto3

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

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

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

Specify:

  • <python_file_name> — file name;
  • <uuid> — unique identifier of the bucket, can be viewed in the bucket's public domain;
  • <path_to_object> — path to the object in the baket.