![]() |
App Engine Python SDK
v1.6.9 rev.445
The Python runtime is available as an experimental Preview feature.
|
Public Member Functions | |
def | __init__ |
def | post_start_creation |
def | put_empty |
def | put_continue_creation |
def | put_copy |
def | get_bucket |
def | get_object |
def | head_object |
def | delete_object |
Public Attributes | |
blob_storage | |
Google Cloud Storage stub implementation. We use blobstore stub to store files. All metadata are stored in _AE_GCSFileInfo_. Note: this Google Cloud Storage stub is designed to work with apphosting.ext.cloudstorage.storage_api.py. It only implements the part of GCS storage_api.py uses, and its interface maps to GCS XML APIs.
def google.appengine.ext.cloudstorage.cloudstorage_stub.CloudStorageStub.__init__ | ( | self, | |
blob_storage | |||
) |
Initialize. Args: blob_storage: apphosting.api.blobstore.blobstore_stub.BlobStorage instance
def google.appengine.ext.cloudstorage.cloudstorage_stub.CloudStorageStub.delete_object | ( | self, | |
filename | |||
) |
Delete file with a DELETE. Args: filename: gcs filename of form '/bucket/filename' Returns: True if file is deleted. False if file doesn't exist.
def google.appengine.ext.cloudstorage.cloudstorage_stub.CloudStorageStub.get_bucket | ( | self, | |
bucketpath, | |||
prefix, | |||
marker, | |||
max_keys, | |||
delimiter | |||
) |
Get bucket listing with a GET. How GCS listbucket work in production: GCS tries to return as many items as possible in a single response. If there are more items satisfying user's query and the current request took too long (e.g spent on skipping files in a subdir) or items to return gets too big (> max_keys), it returns fast and sets IsTruncated and NextMarker for continuation. They serve redundant purpose: if NextMarker is set, IsTruncated is True. Note NextMarker is not where GCS scan left off. It is only valid for the exact same type of query the marker was generated from. For example, if a marker is generated from query with delimiter, the marker is the name of a subdir (instead of the last file within the subdir). Thus you can't use this marker to issue a query without delimiter. Args: bucketpath: gcs bucket path of form '/bucket' prefix: prefix to limit listing. marker: a str after which to start listing. Exclusive. max_keys: max items we scan & return. delimiter: delimiter for directory. See https://developers.google.com/storage/docs/reference-methods#getbucket for details. Returns: A tuple of (a list of GCSFileStat for files or directories sorted by filename, next_marker to use as next marker, is_truncated boolean to indicate if there are more results satisfying query).
def google.appengine.ext.cloudstorage.cloudstorage_stub.CloudStorageStub.get_object | ( | self, | |
filename, | |||
start = 0 , |
|||
end = None |
|||
) |
Get file content with a GET. Args: filename: gcs filename of form '/bucket/filename'. start: start offset to request. Inclusive. end: end offset to request. Inclusive. Returns: The segment of file content requested. Raises: ValueError: if file doesn't exist.
def google.appengine.ext.cloudstorage.cloudstorage_stub.CloudStorageStub.head_object | ( | self, | |
filename | |||
) |
Get file stat with a HEAD. Args: filename: gcs filename of form '/bucket/filename' Returns: A GCSFileStat object containing file stat. None if file doesn't exist.
def google.appengine.ext.cloudstorage.cloudstorage_stub.CloudStorageStub.post_start_creation | ( | self, | |
filename, | |||
options | |||
) |
Start object creation with a POST. This implements the resumable upload XML API. Only major limitation of current implementation is that we don't support multiple upload sessions for the same GCS file. Previous _AE_GCSFileInfo (which represents either a finalized file, or an upload session) will be removed when a new upload session is created. Args: filename: gcs filename of form /bucket/filename. options: a dict containing all user specified request headers. e.g. {'content-type': 'foo', 'x-goog-meta-bar': 'bar'}. Returns: a token (blobkey) used for continuing upload.
def google.appengine.ext.cloudstorage.cloudstorage_stub.CloudStorageStub.put_continue_creation | ( | self, | |
token, | |||
content, | |||
content_range, | |||
length = None , |
|||
_upload_filename = None |
|||
) |
Continue object upload with PUTs. This implements the resumable upload XML API. Args: token: upload token returned by post_start_creation. content: object content. None if no content was provided with this PUT request. content_range: a (start, end) tuple specifying the content range of this chunk. Both are inclusive according to XML API. None is content is None. length: file length, if this is the last chunk of file content. _upload_filename: internal use. Might be removed any time! This is used by blobstore to pass in the upload filename from user. Returns: _AE_GCSFileInfo entity for this file if the file is finalized. Raises: ValueError: if something is invalid. The exception.args is a tuple of (msg, http status code).
def google.appengine.ext.cloudstorage.cloudstorage_stub.CloudStorageStub.put_copy | ( | self, | |
src, | |||
dst, | |||
options | |||
) |
Copy file from src to dst. Metadata is copied. Args: src: /bucket/filename. This file must exist. dst: /bucket/filename. options: a dict containing all user specified request headers. e.g. {'content-type': 'foo', 'x-goog-meta-bar': 'bar'}. If None, old metadata is copied.
def google.appengine.ext.cloudstorage.cloudstorage_stub.CloudStorageStub.put_empty | ( | self, | |
token | |||
) |
Empty put is used to query upload progress. The file must has not finished upload. Args: token: upload token returned by post_start_creation. Returns: last offset uploaded. -1 if none has been uploaded. Raises: ValueError: if token matches no in progress uploads.