Uploading an object
You can create folders inside buckets and upload objects there. Keep in mind that in the SDK and HTTP API, an object key is the entire path to the object from the bucket root. For more information, see Objects.
Note
You cannot upload objects greater than 5 GB in size via the management console (see Quotas and limits in Object Storage). Also, when uploading via the console, you can't set content-type
or other headers. To upload large objects or specify object headers, use other tools.
In the management console, you can work with Object Storage buckets like a hierarchical file system.
To upload an object:
- In the management console, select the folder to upload an object to.
- Select Object Storage.
- Click the name of the desired bucket.
- If you want to upload the object to a particular folder, go to that folder by clicking on its name. If you want to create a new folder, click Create folder.
- Once you are in the appropriate folder, click Upload.
- In the window that opens, select the required files and click Open.
- The management console displays all the objects selected for uploading and prompts you to select a storage class. The default storage class is defined in the bucket settings.
- Click Upload.
- Refresh the page.
To load all objects from the local directory, use the following command:
aws --endpoint-url=https://storage.yandexcloud.net/ \
s3 cp --recursive <path to local directory>/ s3://<bucket name>/<prefix>/
Where:
<path to local directory>
: Path to the folder on your device that contains the files to copy.<bucket name>
: Name of your bucket.<prefix>
: ID of a folder in storage, described in Directory.
Example of creating an object in an existing bucket.
If you do not have Terraform yet, install it and configure the Yandex Cloud provider.
Before you start, retrieve the static access keys: a secret key and a key ID used for authentication in Object Storage.
-
In the configuration file, describe the parameters of resources that you want to create:
provider "yandex" { token = "<OAuth>" cloud_id = "<cloud ID>" folder_id = "<folder ID>" zone = "ru-central1-a" } resource "yandex_storage_object" "test-object" { access_key = "<static key ID>" # Static access key ID. secret_key = "<secret key>" # Secret access key value. bucket = "<bucket name>" # Name of the bucket to add an object to. Required parameter. key = "<object name>" # Name of object in bucket. Required parameter. source = "<file path>" # Relative or absolute path to a file uploaded as an object. }
For more information about the resources you can create using Terraform, see the provider documentation.
-
Make sure that the configuration files are correct.
-
In the command line, go to the directory where you created the configuration file.
-
Run the check using the command:
terraform plan
If the configuration is described correctly, the terminal displays a list of created resources and their parameters. If there are errors in the configuration, Terraform points them out.
-
-
Deploy the cloud resources.
-
If the configuration doesn't contain any errors, run the command:
terraform apply
-
Confirm that you want to create the resources.
Afterwards, all the necessary resources are created in the specified folder. You can check that the resources are there with the correct settings using the management console.
-