A list of Google Cloud Storage predefined (canned) ACL strings.
A list of supported ACL permissions.
Represents a Google Cloud Storage bucket.
Convenience method that provides a quick way to add an email grant to a bucket. This method retrieves the current ACL, creates a new grant based on the parameters passed in, adds that grant to the ACL and then PUT’s the new ACL back to GCS.
Parameters: |
|
---|
Convenience method that provides a quick way to add an email group grant to a bucket. This method retrieves the current ACL, creates a new grant based on the parameters passed in, adds that grant to the ACL and then PUT’s the new ACL back to GCS.
Parameters: |
|
---|
Convenience method that provides a quick way to add a canonical user grant to a bucket. This method retrieves the current ACL, creates a new grant based on the parameters passed in, adds that grant to the ACL and then PUTs the new ACL back to GCS.
Parameters: |
|
---|
To verify that all parts have been removed, so you don’t get charged for the part storage, you should call the List Parts operation and ensure the parts list is empty.
Complete a multipart upload operation.
Configure lifecycle for this bucket.
Parameters: | lifecycle_config (boto.gs.lifecycle.LifecycleConfig) – The lifecycle configuration you want to configure for this bucket. |
---|
Configure versioning for this bucket.
Parameters: |
---|
Configure this bucket to act as a website
Parameters: |
|
---|
Create a new key in the bucket by copying an existing key.
Parameters: |
|
---|---|
Return type: | |
Returns: | An instance of the newly created key object |
Removes all CORS configuration from the bucket.
Deletes a key from the bucket.
Parameters: |
|
---|---|
Return type: | |
Returns: | A key object holding information on what was deleted. |
Deletes a set of keys using S3’s Multi-object delete API. If a VersionID is specified for that key then that version is removed. Returns a MultiDeleteResult Object, which contains Deleted and Error elements for each key you ask to delete.
Parameters: |
|
---|---|
Returns: | An instance of MultiDeleteResult |
Removes all lifecycle configuration from the bucket.
Remove the website configuration from this bucket.
Parameters: | headers (dict) – Additional headers to send with the request. |
---|
Disable logging on this bucket.
Parameters: | headers (dict) – Additional headers to send with the request. |
---|
Enable logging on a bucket.
Parameters: |
---|
Returns the ACL of the bucket or an object in the bucket.
Parameters: |
|
---|---|
Return type: |
A lower-level method for listing contents of a bucket. This closely models the actual S3 API and requires you to manually handle the paging of results. For a higher-level method that handles the details of paging for you, you can use the list method.
Parameters: |
|
---|---|
Return type: | ResultSet |
Returns: | The result from S3 listing the keys requested |
A lower-level, version-aware method for listing active MultiPart uploads for a bucket. This closely models the actual S3 API and requires you to manually handle the paging of results. For a higher-level method that handles the details of paging for you, you can use the list method.
Parameters: |
|
---|---|
Return type: | ResultSet |
Returns: | The result from S3 listing the uploads requested |
A lower-level, version-aware method for listing contents of a bucket. This closely models the actual S3 API and requires you to manually handle the paging of results. For a higher-level method that handles the details of paging for you, you can use the list method.
Parameters: |
|
---|---|
Return type: | ResultSet |
Returns: | The result from S3 listing the keys requested |
Returns a bucket’s CORS XML document.
Parameters: | headers (dict) – Additional headers to send with the request. |
---|---|
Return type: | Cors |
Returns the current CORS configuration on the bucket as an XML document.
Returns the bucket’s default ACL.
Parameters: | headers (dict) – Additional headers to set during the request. |
---|---|
Return type: | gs.acl.ACL |
Returns a Key instance for an object in this bucket.
Note that this method uses a HEAD request to check for the existence of the key.
Parameters: |
|
---|---|
Return type: | |
Returns: | A Key object from this bucket. |
Returns the current lifecycle configuration on the bucket.
Return type: | boto.gs.lifecycle.LifecycleConfig |
---|---|
Returns: | A LifecycleConfig object that describes all current lifecycle rules in effect for the bucket. |
Returns the LocationConstraint for the bucket.
Return type: | str |
---|---|
Returns: | The LocationConstraint for the bucket or the empty string if no constraint was specified when bucket was created. |
Returns the current status of logging configuration on the bucket.
Parameters: | headers (dict) – Additional headers to send with the request. |
---|---|
Return type: | dict |
Returns: | A dictionary containing the parsed XML response from GCS. The
overall structure is:
|
Returns the current status of logging configuration on the bucket as unparsed XML.
Parameters: | headers (dict) – Additional headers to send with the request. |
---|---|
Return type: | 2-Tuple |
Returns: | 2-tuple containing:
|
Get the logging status for this bucket.
Return type: | boto.s3.bucketlogging.BucketLogging |
---|---|
Returns: | A BucketLogging object for this bucket. |
Returns the JSON policy associated with the bucket. The policy is returned as an uninterpreted JSON string.
Returns the StorageClass for the bucket.
Return type: | str |
---|---|
Returns: | The StorageClass for the bucket. |
Get a subresource for a bucket or key.
Parameters: |
|
---|---|
Return type: | string |
Returns: | The value of the subresource. |
Returns the current status of versioning configuration on the bucket.
Return type: | bool |
---|
Returns the current status of website configuration on the bucket.
Parameters: | headers (dict) – Additional headers to send with the request. |
---|---|
Return type: | dict |
Returns: | A dictionary containing the parsed XML response from GCS. The
overall structure is:
|
Get the website configuration as a boto.s3.website.WebsiteConfiguration object.
Returns the current status of website configuration on the bucket as unparsed XML.
Parameters: | headers (dict) – Additional headers to send with the request. |
---|---|
Return type: | 2-Tuple |
Returns: | 2-tuple containing:
|
Get raw website configuration xml
Returns the fully qualified hostname to use is you want to access this bucket as a website. This doesn’t validate whether the bucket has been correctly configured as a website or not.
Returns the ACL string of the bucket or an object in the bucket.
Parameters: |
|
---|---|
Return type: | str |
Start a multipart upload operation.
Note
Note: After you initiate multipart upload and upload one or more parts, you must either complete or abort multipart upload in order to stop getting charged for storage of the uploaded parts. Only after you either complete or abort multipart upload, Amazon S3 frees up the parts storage and stops charging you for the parts storage.
Parameters: |
|
---|
List key objects within a bucket. This returns an instance of an BucketListResultSet that automatically handles all of the result paging, etc. from S3. You just need to keep iterating until there are no more results.
Called with no arguments, this will return an iterator object across all keys within the bucket.
The Key objects returned by the iterator are obtained by parsing the results of a GET on the bucket, also known as the List Objects request. The XML returned by this request contains only a subset of the information about each key. Certain metadata fields such as Content-Type and user metadata are not available in the XML. Therefore, if you want these additional metadata fields you will have to do a HEAD request on the Key in the bucket.
Parameters: |
|
---|---|
Return type: | |
Returns: | an instance of a BucketListResultSet that handles paging, etc |
Returns the ACL entries applied to this bucket.
Parameters: | headers (dict) – Additional headers to send with the request. |
---|---|
Return type: | list containing Entry objects. |
List multipart upload objects within a bucket. This returns an instance of an MultiPartUploadListResultSet that automatically handles all of the result paging, etc. from S3. You just need to keep iterating until there are no more results.
Parameters: |
|
---|---|
Return type: | |
Returns: | an instance of a BucketListResultSet that handles paging, etc |
List versioned objects within a bucket. This returns an instance of an VersionedBucketListResultSet that automatically handles all of the result paging, etc. from GCS. You just need to keep iterating until there are no more results. Called with no arguments, this will return an iterator object across all keys within the bucket.
Parameters: |
|
---|---|
Return type: | |
Returns: | an instance of a BucketListResultSet that handles paging, etc. |
Deprecated: Please use get_key method.
Parameters: | key_name (string) – The name of the key to retrieve |
---|---|
Return type: | boto.s3.key.Key |
Returns: | A Key object from this bucket. |
Creates a new key
Parameters: | key_name (string) – The name of the key to create |
---|---|
Return type: | boto.s3.key.Key or subclass |
Returns: | An instance of the newly created key object |
Sets or changes a bucket’s or key’s ACL.
Parameters: |
|
---|
Setup the current bucket as a logging target by granting the necessary permissions to the LogDelivery group to write log files to this bucket.
Sets a bucket’s or objects’s ACL using a predefined (canned) value.
Parameters: |
|
---|
Sets a bucket’s CORS XML document.
Parameters: |
---|
Set the CORS (Cross-Origin Resource Sharing) for a bucket.
Parameters: | cors_xml (str) – The XML document describing your desired CORS configuration. See the S3 documentation for details of the exact syntax required. |
---|
Sets or changes a bucket’s default ACL.
Parameters: |
|
---|
Sets a bucket’s default ACL using a predefined (canned) value.
Parameters: |
|
---|
Sets a bucket’s default ACL to an XML string.
Parameters: |
---|
Set the Key class associated with this bucket. By default, this would be the boto.s3.key.Key class but if you want to subclass that for some reason this allows you to associate your new class with a bucket so that when you call bucket.new_key() or when you get a listing of keys in the bucket you will get an instances of your key class rather than the default.
Parameters: | key_class (class) – A subclass of Key that can be more specific |
---|
Add or replace the JSON policy associated with the bucket.
Parameters: | policy (str) – The JSON policy as a string. |
---|
Set a subresource for a bucket or key.
Parameters: |
|
---|
Parameters: | config (boto.s3.website.WebsiteConfiguration) – Configuration data |
---|
Upload xml website configuration
Sets a bucket’s or objects’s ACL to an XML string.
Parameters: |
|
---|
Set logging on a bucket directly to the given xml string.
Parameters: | logging_str (unicode string) – The XML for the bucketloggingstatus which will be set. The string will be converted to utf-8 before it is sent. Usually, you will obtain this XML from the BucketLogging object. |
---|---|
Return type: | bool |
Returns: | True if ok or raises an exception. |
See documentation in boto/s3/bucket.py.
A resultset for listing versions within a bucket. Uses the bucket_lister generator function and implements the iterator interface. This transparently handles the results paging from GCS so even if you have many thousands of keys within the bucket you can iterate over all keys in a reasonably efficient manner.
A generator function for listing versioned objects.
Taken from the AWS book Python examples and modified for use with boto This only returns the arguments required for the post form, not the actual form. This does not return the file input field which also needs to be added
Parameters: |
|
---|---|
Return type: | dict |
Returns: | A dictionary containing field names/values as well as a url to POST to
|
Taken from the AWS book Python examples and modified for use with boto
(Optional) Close any open HTTP connections. This is non-destructive, and making a new request will open a connection again.
Creates a new bucket. By default it’s located in the USA. You can pass Location.EU to create bucket in the EU. You can also pass a LocationConstraint for where the bucket should be located, and a StorageClass describing how the data should be stored.
Parameters: |
|
---|
Removes an S3 bucket.
In order to remove the bucket, it must first be empty. If the bucket is not empty, an S3ResponseError will be raised.
Parameters: |
---|
Retrieves a bucket by name.
If the bucket does not exist, an S3ResponseError will be raised. If you are unsure if the bucket exists or not, you can use the S3Connection.lookup method, which will either return a valid bucket or None.
Parameters: |
---|
Convenience method that returns the “CanonicalUserID” of the user who’s credentials are associated with the connection. The only way to get this value is to do a GET request on the service which returns all buckets associated with the account. As part of that response, the canonical userid is returned. This method simply does all of that and then returns just the user id.
Return type: | string |
---|---|
Returns: | A string containing the canonical user id. |
Determines if a bucket exists by name.
If the bucket does not exist, an S3ResponseError will be raised.
Parameters: | |
---|---|
Returns: | A <Bucket> object |
Attempts to get a bucket from S3.
Works identically to S3Connection.get_bucket, save for that it will return None if the bucket does not exist instead of throwing an exception.
Parameters: |
---|
Set the Bucket class associated with this bucket. By default, this would be the boto.s3.key.Bucket class but if you want to subclass that for some reason this allows you to associate your new class.
Parameters: | bucket_class (class) – A subclass of Bucket that can be more specific |
---|
Encapsulates the CORS configuration XML document
SAX XML logic for parsing new element found.
SAX XML logic for parsing new element found.
Convert CORS object into XML string representation.
Verify parse level for a given tag.
Represents a key (object) in a GS bucket.
Variables: |
|
---|
Convenience method that provides a quick way to add an email grant to a key. This method retrieves the current ACL, creates a new grant based on the parameters passed in, adds that grant to the ACL and then PUT’s the new ACL back to GS.
Parameters: |
|
---|
Convenience method that provides a quick way to add an email group grant to a key. This method retrieves the current ACL, creates a new grant based on the parameters passed in, adds that grant to the ACL and then PUT’s the new ACL back to GS.
Parameters: |
|
---|
Convenience method that provides a quick way to add a canonical group grant to a key. This method retrieves the current ACL, creates a new grant based on the parameters passed in, adds that grant to the ACL and then PUT’s the new ACL back to GS.
Parameters: |
|
---|
Convenience method that provides a quick way to add a canonical user grant to a key. This method retrieves the current ACL, creates a new grant based on the parameters passed in, adds that grant to the ACL and then PUT’s the new ACL back to GS.
Parameters: |
|
---|
Change the storage class of an existing key. Depending on whether a different destination bucket is supplied or not, this will either move the item within the bucket, preserving all metadata and ACL info bucket changing the storage class or it will copy the item to the provided destination bucket, also preserving metadata and ACL info.
Parameters: |
|
---|
Close this key.
Parameters: | fast (bool) – True if you want the connection to be closed without first |
---|
reading the content. This should only be used in cases where subsequent calls don’t need to return the content from the open HTTP connection. Note: As explained at http://docs.python.org/2/library/httplib.html#httplib.HTTPConnection.getresponse, callers must read the whole response before sending a new request to the server. Calling Key.close(fast=True) and making a subsequent request to the server will work because boto will get an httplib exception and close/reopen the connection.
Create a new object from a sequence of existing objects.
The content of the object representing this Key will be the concatenation of the given object sequence. For more detail, visit
:type components list of Keys :param components List of gs.Keys representing the component objects
:type content_type (optional) string :param content_type Content type for the new composite object.
Parameters: |
|
---|
Parameters: |
|
---|
Copy this Key to another bucket.
Parameters: |
|
---|---|
Return type: | boto.s3.key.Key or subclass |
Returns: | An instance of the newly created key object |
Returns True if the key exists
Return type: | bool |
---|---|
Returns: | Whether the key exists on S3 |
Generate a URL to access this key.
Parameters: |
|
---|---|
Return type: | string |
Returns: | The URL to access the key |
Returns the ACL of this object.
Parameters: | |
---|---|
Return type: |
Retrieve an object from S3 using the name of the Key object as the key in S3. Return the contents of the object as a string. See get_contents_to_file method for details about the parameters.
Parameters: |
|
---|---|
Return type: | bytes or str |
Returns: | The contents of the file as bytes or a string |
Retrieve an object from GCS using the name of the Key object as the key in GCS. Write the contents of the object to the file pointed to by ‘fp’.
Parameters: |
|
---|
Retrieve an object from S3 using the name of the Key object as the key in S3. Store contents of the object to a file named by ‘filename’. See get_contents_to_file method for details about the parameters.
Parameters: |
|
---|
A utility function to create the 2-tuple (md5hexdigest, base64md5) from just having a precalculated md5_hexdigest.
Return the redirect location configured for this key.
If no redirect is configured (via set_redirect), then None will be returned.
Get a torrent file (see to get_file)
Parameters: |
|
---|
Returns the ACL string of this object.
Parameters: | |
---|---|
Return type: | str |
By providing a next method, the key object supports use as an iterator. For example, you can now say:
All of the HTTP connection stuff is handled for you.
Open this key for reading
Parameters: |
|
---|
Open this key for writing. Not yet implemented
Parameters: |
---|
Restore an object from an archive.
Parameters: | days (int) – The lifetime of the restored object (must be at least 1 day). If the object is already restored then this parameter can be used to readjust the lifetime of the restored object. In this case, the days param is with respect to the initial time of the request. If the object has not been restored, this param is with respect to the completion time of the request. |
---|
Upload a file to GCS.
Parameters: |
|
---|
Sets the ACL for this object.
Parameters: |
|
---|
Sets this objects’s ACL using a predefined (canned) value.
Parameters: |
|
---|
Store an object in GS using the name of the Key object as the key in GS and the contents of the file pointed to by ‘fp’ as the contents.
Parameters: |
|
---|---|
Return type: | int |
Returns: | The number of bytes written to the key. |
TODO: At some point we should refactor the Bucket and Key classes, to move functionality common to all providers into a parent class, and provider-specific functionality into subclasses (rather than just overriding/sharing code the way it currently works).
Store an object in GS using the name of the Key object as the key in GS and the contents of the file named by ‘filename’. See set_contents_from_file method for details about the parameters.
Parameters: |
|
---|
Store an object using the name of the Key object as the key in cloud and the contents of the data stream pointed to by ‘fp’ as the contents.
The stream object is not seekable and total size is not known. This has the implication that we can’t specify the Content-Size and Content-MD5 in the header. So for huge uploads, the delay in calculating MD5 is avoided but with a penalty of inability to verify the integrity of the uploaded data.
Parameters: |
|
---|
Store an object in GCS using the name of the Key object as the key in GCS and the string ‘s’ as the contents. See set_contents_from_file method for details about the parameters.
Parameters: |
|
---|
Configure this key to redirect to another location.
When the bucket associated with this key is accessed from the website endpoint, a 301 redirect will be issued to the specified redirect_location.
Parameters: | redirect_location (string) – The location to redirect. |
---|
Sets this objects’s ACL to an XML string.
Parameters: |
|
---|
Constructor. Instantiate once for each uploaded file.
Parameters: |
|
---|
Returns upload tracker URI, or None if the upload has not yet started.
Returns the upload ID for the resumable upload, or None if the upload has not yet started.
Upload a file to a key into a bucket on GS, using GS resumable upload protocol.
Parameters: |
|
---|
Raises ResumableUploadException if a problem occurs during the transfer.