This page describes options for uploading objects to your Cloud Storage bucket. An uploaded object consists of the data you want to store along with any associated metadata. For an overview of objects, read the Key Terms and see the Object naming requirements.
Console
- Open the Cloud Storage browser in the Google Cloud Console.
Open the Cloud Storage browser In the list of buckets, click on the name of the bucket that you want to upload an object to.
In the Objects tab for the bucket, either:
Drag and drop the desired files from your desktop or file manager to the main pane in the Cloud Console.
Click the Upload Files button, select the files you want to upload in the dialog that appears, and click Open.
gsutil
Use the gsutil cp
command:
gsutil cp [OBJECT_LOCATION] gs://[DESTINATION_BUCKET_NAME]/
Where:
[OBJECT_LOCATION]
is the local path to your object. For example,Desktop/dog.png
.[DESTINATION_BUCKET_NAME]
is the name of the bucket to which you are uploading your object. For example,my-bucket
.
If successful, the response looks like the following example:
Operation completed over 1 objects/58.8 KiB.
Code samples
For more information, see the
Cloud Storage C++ API reference documentation
.
For more information, see the
Cloud Storage C# API reference documentation
.
For more information, see the
Cloud Storage Go API reference documentation
.
For more information, see the
Cloud Storage Java API reference documentation
.
For more information, see the
Cloud Storage Node.js API reference documentation
.
For more information, see the
Cloud Storage PHP API reference documentation
.
For more information, see the
Cloud Storage Python API reference documentation
.
For more information, see the
Cloud Storage Ruby API reference documentation
.
C++
C#
Go
Java
Node.js
PHP
Python
Ruby
REST APIs
JSON API
- Get an authorization access token from the OAuth 2.0 Playground. Configure the playground to use your own OAuth credentials.
Use
cURL
to call the JSON API with aPOST
Object request:curl -X POST --data-binary @[OBJECT_LOCATION] \ -H "Authorization: Bearer [OAUTH2_TOKEN]" \ -H "Content-Type: [OBJECT_CONTENT_TYPE]" \ "https://storage.googleapis.com/upload/storage/v1/b/[BUCKET_NAME]/o?uploadType=media&name=[OBJECT_NAME]"
Where:
[OBJECT_LOCATION]
is the local path to your object. For example,Desktop/dog.png
.[OAUTH2_TOKEN]
is the access token you generated in Step 1.[OBJECT_CONTENT_TYPE]
is the content type of the object. For example,image/png
.[BUCKET_NAME]
is the name of the bucket to which you are uploading your object. For example,my-bucket
.[OBJECT_NAME]
is the name you want to give your object. For example,pets/dog.png
.
XML API
- Get an authorization access token from the OAuth 2.0 Playground. Configure the playground to use your own OAuth credentials.
Use
cURL
to call the XML API with aPUT
Object request:curl -X PUT --data-binary @[OBJECT_LOCATION] \ -H "Authorization: Bearer [OAUTH2_TOKEN]" \ -H "Content-Type: [OBJECT_CONTENT_TYPE]" \ "https://storage.googleapis.com/[BUCKET_NAME]/[OBJECT_NAME]"
Where:
[OBJECT_LOCATION]
is the local path to your object. For example,Desktop/dog.png
.[OAUTH2_TOKEN]
is the access token you generated in Step 1.[OBJECT_CONTENT_TYPE]
is the content type of the object. For example,image/png
.[BUCKET_NAME]
is the name of the bucket to which you are uploading your object. For example,my-bucket
.[OBJECT_NAME]
is the name you want to give your object. For example,pets/dog.png
.
What's next
- Make your data publicly accessible.
- View and edit your object metadata.
- Learn how to work with objects in your Cloud Storage buckets.
- Control who has access to your objects and buckets.
- Learn about parallel uploads and composing objects.