Make Objects Publicly Accessible

In this section, you will learn how to make an object in your S3 bucket publicly accessible, allowing it to be retrieved over the internet.

Step 1: Upload the Object

Upload the object to your S3 bucket.

aws s3api put-object --bucket <bucketname> --key <object-key> --body <local-file-path> --endpoint-url=https://<endpoint-url>

Explanation of variables:

  • <bucketname>: The name of the bucket where you want to upload the object.
  • <object-key>: The desired location and name of the object in the bucket.
  • <local-file-path>: The path and name of the local file to be uploaded.
  • <endpoint-url>: The corresponding endpoint for your plusserver S3 service.

Example:

aws s3api put-object --bucket mybucket --key public-folder/mypublicobject.pdf --body /path/to/mypublicobject.pdf --endpoint-url=https://s3.de-west-1.psmanaged.com

Step 2: Generate the Public URL

Generate the public URL of the object, allowing you to download it over the internet.

aws s3 presign s3://<bucketname>/<object-key> --endpoint-url=https://<endpoint-url>

Explanation of variables:

  • <bucketname>: The name of the bucket where the object is located.
  • <object-key>: The path and name of the object in the bucket.
  • <endpoint-url>: The corresponding endpoint for your plusserver S3 service.

Example:

aws s3 presign s3://mybucket/public-folder/mypublicobject.pdf --endpoint-url=https://s3.de-west-1.psmanaged.com

The command will output the URL through which the object is accessible over the internet.

By default, the validity period of the link generated by the presign command is 7 days. To modify the validity period of a presign link, you can use the --expires-in option. Here is an example of how to set the validity period to 3 days:

aws s3 presign s3://<bucketname>/<objekt-key> --expires-in 259200 --endpoint-url=https://<endpoint-url>

Explanation:

--expires-in 259200: Sets the validity period to 3 days (3 days * 24 hours/day * 60 minutes/hour * 60 seconds/minute).

Default is 3600 seconds. Maximum is 604800 seconds.

Last modified 03.05.2024: dos2unix mansvc files (d79b1ea)