a
    !f                     @   sX  d Z ddlZddlZddlZddlmZ ddlmZ ddlZddlZddl	Z	ddl
Z
ddlZddlZddlmZ ddlmZ ddlmZ ddlmZ dd	lmZ dd
lmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddl m!Z! ddl m"Z" ddl m#Z# dZ$G dd deZ%G dd de&Z'G dd de&Z(dd Z)dS )z2Create / interact with Google Cloud Storage blobs.    N)BytesIO)UnsupportedOperationquote)_rfc3339_to_datetime)	_to_bytes)_bytes_to_unicode)generate_signed_url)NotFound)make_exception)_PropertyMixin)_scalar_property)	ObjectACL)Request)make_api_request)Download)RESUMABLE_UPLOAD)Uploadhttps://storage.googleapis.comc                       s  e Zd ZdZdZdZdQ fdd	Zedd Zej	dd Ze
d	d
 Zedd Zdd Zedd Zedd Zedd ZdRddZdSddZdTddZdUddZdVddZdWd d!Ze
d"d# ZdXd&d'ZdYd(d)ZdZd+d,Zd[d-d.Zed/Zed0Zed1Zed2Z ed3Z!ed4Z"ed5d6 Z#ed7d8 Z$ed9d: Z%ed;d< Z&ed=Z'ed>d? Z(ed@dA Z)e)j	dBdA Z)edCdD Z*edEdF Z+edGdH Z,edIdJ Z-edKdL Z.edMdN Z/edOdP Z0  Z1S )\Bloba  A wrapper around Cloud Storage's concept of an ``Object``.

    :type name: string
    :param name: The name of the blob.  This corresponds to the
                 unique path of the object in the bucket.

    :type bucket: :class:`gcloud.storage.bucket.Bucket`
    :param bucket: The bucket to which this blob belongs.

    :type chunk_size: integer
    :param chunk_size: The size of a chunk of data whenever iterating (1 MB).
                       This must be a multiple of 256 KB per the API
                       specification.
    Ni   c                    s,   t t| j|d || _|| _t| | _d S )N)name)superr   __init__
chunk_sizebucketr   _acl)selfr   r   r   	__class__ T/var/www/html/python-backend/venv/lib/python3.9/site-packages/gcloud/storage/blob.pyr   G   s    zBlob.__init__c                 C   s   | j S )zGet the blob's default chunk size.

        :rtype: integer or ``NoneType``
        :returns: The current blob's chunk size, if it is set.
        )_chunk_sizer   r   r   r    r   N   s    zBlob.chunk_sizec                 C   s0   |dur&|| j  dkr&td| j f || _dS )a  Set the blob's default chunk size.

        :type value: integer or ``NoneType``
        :param value: The current blob's chunk size, if it is set.

        :raises: :class:`ValueError` if ``value`` is not ``None`` and is not a
                 multiple of 256 KB.
        Nr   z$Chunk size must be a multiple of %d.)_CHUNK_SIZE_MULTIPLE
ValueErrorr!   r   valuer   r   r    r   W   s
    
c                 C   s   | d t |dd S )a$  Relative URL path for a blob.

        :type bucket_path: string
        :param bucket_path: The URL path for a bucket.

        :type blob_name: string
        :param blob_name: The name of the blob.

        :rtype: string
        :returns: The relative URL path for ``blob_name``.
        z/o/ safer   )Zbucket_pathZ	blob_namer   r   r    path_helperf   s    zBlob.path_helperc                 C   s   | j S )zCreate our ACL on demand.)r   r"   r   r   r    aclu   s    zBlob.aclc                 C   s"   | j r| j j}nd }d|| jf S )Nz<Blob: %s, %s>)r   r   )r   bucket_namer   r   r    __repr__z   s    
zBlob.__repr__c                 C   s    | j std| | jj| j S )z|Getter property for the URL path to this Blob.

        :rtype: string
        :returns: The URL path to this Blob.
        z*Cannot determine path without a blob name.)r   r$   r*   r   pathr"   r   r   r    r.      s    z	Blob.pathc                 C   s   | j jS )zThe client bound to this blob.)r   clientr"   r   r   r    r/      s    zBlob.clientc                 C   s   dj d| jjt| jdddS )zyThe public URL for this blob's object.

        :rtype: `string`
        :returns: The public URL for this blob.
        z.{storage_base_url}/{bucket_name}/{quoted_name}r   r'   r(   )Zstorage_base_urlr,   quoted_name)formatr   r   r   r"   r   r   r    
public_url   s
    zBlob.public_urlGETc	           
      C   sP   dj | jjt| jddd}	|du r6| |}|jj}t||	t||||||d	S )a
  Generates a signed URL for this blob.

        .. note::

            If you are on Google Compute Engine, you can't generate a signed
            URL. Follow `Issue 922`_ for updates on this. If you'd like to
            be able to generate a signed URL from GCE, you can use a standard
            service account from a JSON file rather than a GCE service account.

        .. _Issue 922: https://github.com/GoogleCloudPlatform/                       gcloud-python/issues/922

        If you have a blob that you want to allow access to for a set
        amount of time, you can use this method to generate a URL that
        is only valid within a certain time period.

        This is particularly useful if you don't want publicly
        accessible blobs, but don't want to require users to explicitly
        log in.

        :type expiration: int, long, datetime.datetime, datetime.timedelta
        :param expiration: When the signed URL should expire.

        :type method: str
        :param method: The HTTP verb that will be used when requesting the URL.

        :type content_type: str
        :param content_type: (Optional) The content type of the object
                             referenced by ``resource``.

        :type generation: str
        :param generation: (Optional) A value that indicates which generation
                           of the resource to fetch.

        :type response_disposition: str
        :param response_disposition: (Optional) Content disposition of
                                     responses to requests for the signed URL.
                                     For example, to enable the signed URL
                                     to initiate a file of ``blog.png``, use
                                     the value
                                     ``'attachment; filename=blob.png'``.

        :type response_type: str
        :param response_type: (Optional) Content type of responses to requests
                              for the signed URL. Used to over-ride the content
                              type of the underlying blob/object.

        :type client: :class:`gcloud.storage.client.Client` or ``NoneType``
        :param client: (Optional) The client to use.  If not passed, falls back
                       to the ``client`` stored on the blob's bucket.


        :type credentials: :class:`oauth2client.client.OAuth2Credentials` or
                           :class:`NoneType`
        :param credentials: (Optional) The OAuth2 credentials to use to sign
                            the URL. Defaults to the credentials stored on the
                            client used.

        :rtype: str
        :returns: A signed URL you can use to access the resource
                  until expiration.
        z/{bucket_name}/{quoted_name}r'   r(   )r,   r0   N)resourceZapi_access_endpoint
expirationmethodcontent_typeresponse_typeresponse_disposition
generation)	r1   r   r   r   _require_client_connectioncredentialsr	   _API_ACCESS_ENDPOINT)
r   r5   r6   r7   r:   r9   r8   r/   r=   r4   r   r   r    r	      s     B
zBlob.generate_signed_urlc                 C   sH   |  |}z$ddi}|jjd| j|dd W dS  tyB   Y dS 0 dS )ak  Determines whether or not this blob exists.

        :type client: :class:`gcloud.storage.client.Client` or ``NoneType``
        :param client: Optional. The client to use.  If not passed, falls back
                       to the ``client`` stored on the blob's bucket.

        :rtype: boolean
        :returns: True if the blob exists in Cloud Storage.
        fieldsr   r3   N)r6   r.   query_paramsZ_target_objectTF)r;   
connectionZapi_requestr.   r
   )r   r/   r@   r   r   r    exists   s    

zBlob.existsc                 C   s   | j j| j|dS )a  Deletes a blob from Cloud Storage.

        :type client: :class:`gcloud.storage.client.Client` or ``NoneType``
        :param client: Optional. The client to use.  If not passed, falls back
                       to the ``client`` stored on the blob's bucket.

        :rtype: :class:`Blob`
        :returns: The blob that was just deleted.
        :raises: :class:`gcloud.exceptions.NotFound`
                 (propagated from
                 :meth:`gcloud.storage.bucket.Bucket.delete_blob`).
        r/   )r   Zdelete_blobr   r   r/   r   r   r    delete  s    zBlob.deletec                 C   sp   |  |}| jdu r|   | j}t|}| jdur>| j|_i }|rPt|| t|d|}|	||j
j dS )ae  Download the contents of this blob into a file-like object.

        .. note::

           If the server-set property, :attr:`media_link`, is not yet
           initialized, makes an additional API request to load it.

         Downloading a file that has been encrypted with a `customer-supplied`_
         encryption key::

            >>> from gcloud import storage
            >>> from gcloud.storage import Blob

            >>> client = storage.Client(project='my-project')
            >>> bucket = client.get_bucket('my-bucket')
            >>> encryption_key = 'aa426195405adee2c8081bb9e7e74b19'
            >>> blob = Blob('secure-data', bucket)
            >>> with open('/tmp/my-secure-file', 'wb') as file_obj:
            >>>     blob.download_to_file(file_obj,
            ...                           encryption_key=encryption_key)

        The ``encryption_key`` should be a str or bytes with a length of at
        least 32.

        .. _customer-supplied: https://cloud.google.com/storage/docs/                               encryption#customer-supplied

        :type file_obj: file
        :param file_obj: A file handle to which to write the blob's data.

        :type encryption_key: str or bytes
        :param encryption_key: Optional 32 byte encryption key for
                               customer-supplied encryption.

        :type client: :class:`gcloud.storage.client.Client` or ``NoneType``
        :param client: Optional. The client to use.  If not passed, falls back
                       to the ``client`` stored on the blob's bucket.

        :raises: :class:`gcloud.exceptions.NotFound`
        Nr3   )r;   
media_linkreloadr   from_streamr   	chunksize_set_encryption_headersr   Zinitialize_downloadr<   http)r   file_objencryption_keyr/   download_urldownloadheadersrequestr   r   r    download_to_file  s    )




zBlob.download_to_filec                 C   s`   t |d }| j|||d W d   n1 s00    Y  t| j }t|j||f dS )a`  Download the contents of this blob into a named file.

        :type filename: string
        :param filename: A filename to be passed to ``open``.

        :type encryption_key: str or bytes
        :param encryption_key: Optional 32 byte encryption key for
                               customer-supplied encryption.

        :type client: :class:`gcloud.storage.client.Client` or ``NoneType``
        :param client: Optional. The client to use.  If not passed, falls back
                       to the ``client`` stored on the blob's bucket.

        :raises: :class:`gcloud.exceptions.NotFound`
        wbrM   r/   N)	openrR   timemktimeupdated	timetupleosutimer   )r   filenamerM   r/   rL   mtimer   r   r    download_to_filename_  s    $zBlob.download_to_filenamec                 C   s   t  }| j|||d | S )aB  Download the contents of this blob as a string.

        :type encryption_key: str or bytes
        :param encryption_key: Optional 32 byte encryption key for
                               customer-supplied encryption.

        :type client: :class:`gcloud.storage.client.Client` or ``NoneType``
        :param client: Optional. The client to use.  If not passed, falls back
                       to the ``client`` stored on the blob's bucket.

        :rtype: bytes
        :returns: The data stored in this blob.
        :raises: :class:`gcloud.exceptions.NotFound`
        rT   )r   rR   getvalue)r   rM   r/   string_bufferr   r   r    download_as_stringv  s
    zBlob.download_as_stringc                 C   sL   |j }t|d }d|  kr&dk sHn td|i}t||j| jddS )z$Helper for :meth:`upload_from_file`.status   i,  )
error_infoN)infointhttplib2Responser   contenturl)rQ   http_responsere   rb   Zfaux_responser   r   r    _check_response_error  s    zBlob._check_response_errorF   c              	   C   s  |  |}|j}|p"| jdp"d}|r6|dtj |}	|	du rxt|drxzt|	 j
}	W n ttfyv   Y n0 dd|jd}
|rt||
 t|||	d	d
}| jdur| j|_|	du rt|_n|	du rtdt| jj| jd}t }|jd }|j|| jjd d}t|d|
}|||| |j}|jd }|j|| jjd |d|_| ||j! |jtkrz|j"dd}nt#|j!||d}| $|| |j%}t&|t'j(s|)d}| *t+,| dS )a  Upload the contents of this blob from a file-like object.

        The content type of the upload will either be
        - The value passed in to the function (if any)
        - The value stored on the current blob
        - The default value of 'application/octet-stream'

        .. note::
           The effect of uploading to an existing blob depends on the
           "versioning" and "lifecycle" policies defined on the blob's
           bucket.  In the absence of those policies, upload will
           overwrite any existing contents.

           See the `object versioning
           <https://cloud.google.com/storage/docs/object-versioning>`_ and
           `lifecycle <https://cloud.google.com/storage/docs/lifecycle>`_
           API documents for details.

        Uploading a file with a `customer-supplied`_ encryption key::

            >>> from gcloud import storage
            >>> from gcloud.storage import Blob

            >>> client = storage.Client(project='my-project')
            >>> bucket = client.get_bucket('my-bucket')
            >>> encryption_key = 'aa426195405adee2c8081bb9e7e74b19'
            >>> blob = Blob('secure-data', bucket)
            >>> with open('my-file', 'rb') as my_file:
            >>>     blob.upload_from_file(my_file,
            ...                           encryption_key=encryption_key)

        The ``encryption_key`` should be a str or bytes with a length of at
        least 32.

        .. _customer-supplied: https://cloud.google.com/storage/docs/                               encryption#customer-supplied

        :type file_obj: file
        :param file_obj: A file handle open for reading.

        :type rewind: boolean
        :param rewind: If True, seek to the beginning of the file handle before
                       writing the file to Cloud Storage.

        :type size: int
        :param size: The number of bytes to read from the file handle.
                     If not provided, we'll try to guess the size using
                     :func:`os.fstat`. (If the file handle is not from the
                     filesystem this won't be possible.)

        :type encryption_key: str or bytes
        :param encryption_key: Optional 32 byte encryption key for
                               customer-supplied encryption.

        :type content_type: string or ``NoneType``
        :param content_type: Optional type of content being uploaded.

        :type num_retries: integer
        :param num_retries: Number of upload retries. Defaults to 6.

        :type client: :class:`gcloud.storage.client.Client` or ``NoneType``
        :param client: Optional. The client to use.  If not passed, falls back
                       to the ``client`` stored on the blob's bucket.

        :raises: :class:`ValueError` if size is not passed in and can not be
                 determined; :class:`gcloud.exceptions.GCloudError` if the
                 upload response returns an error status.
        contentTypezapplication/octet-streamr   Nfilenozapplication/jsonzgzip, deflate)AcceptzAccept-Encodingz
User-AgentF)Zauto_transferzstotal bytes could not be determined. Please pass an explicit size, or supply a chunk size for a streaming transfer.)r,   object_namez/uploadz/o)api_base_urlr.   POST)rr   r.   r@   T)Z
use_chunks)retriesutf-8)-r;   r<   _propertiesgetseekrZ   SEEK_SEThasattrfstatro   st_sizeOSErrorr   Z
USER_AGENTrJ   r   r   rI   r   Zstrategyr$   _UrlBuilderr   r   _UploadConfigZAPI_BASE_URLZbuild_api_urlr.   r   Zconfigure_requestr@   rj   Zinitialize_uploadrK   Zstream_filer   rl   ri   
isinstancesixstring_typesdecodeZ_set_propertiesjsonloads)r   rL   rewindsizerM   r7   Znum_retriesr/   rA   total_bytesrP   uploadZurl_builderZupload_configbase_urlZ
upload_urlrQ   r@   rk   Zresponse_contentr   r   r    upload_from_file  st    G








zBlob.upload_from_filec                 C   sf   |p| j d}|du r&t|\}}t|d"}| j||||d W d   n1 sX0    Y  dS )a\  Upload this blob's contents from the content of a named file.

        The content type of the upload will either be
        - The value passed in to the function (if any)
        - The value stored on the current blob
        - The value given by mimetypes.guess_type

        .. note::
           The effect of uploading to an existing blob depends on the
           "versioning" and "lifecycle" policies defined on the blob's
           bucket.  In the absence of those policies, upload will
           overwrite any existing contents.

           See the `object versioning
           <https://cloud.google.com/storage/docs/object-versioning>`_ and
           `lifecycle <https://cloud.google.com/storage/docs/lifecycle>`_
           API documents for details.

        :type filename: string
        :param filename: The path to the file.

        :type content_type: string or ``NoneType``
        :param content_type: Optional type of content being uploaded.

        :type encryption_key: str or bytes
        :param encryption_key: Optional 32 byte encryption key for
                               customer-supplied encryption.

        :type client: :class:`gcloud.storage.client.Client` or ``NoneType``
        :param client: Optional. The client to use.  If not passed, falls back
                       to the ``client`` stored on the blob's bucket.
        rn   Nrb)r7   rM   r/   )rv   rw   	mimetypes
guess_typerU   r   )r   r\   r7   rM   r/   _rL   r   r   r    upload_from_filename-  s    "zBlob.upload_from_filename
text/plainc                 C   sD   t |tjr|d}t }|| | j|dt||||d dS )a  Upload contents of this blob from the provided string.

        .. note::
           The effect of uploading to an existing blob depends on the
           "versioning" and "lifecycle" policies defined on the blob's
           bucket.  In the absence of those policies, upload will
           overwrite any existing contents.

           See the `object versioning
           <https://cloud.google.com/storage/docs/object-versioning>`_ and
           `lifecycle <https://cloud.google.com/storage/docs/lifecycle>`_
           API documents for details.

        :type data: bytes or text
        :param data: The data to store in this blob.  If the value is
                     text, it will be encoded as UTF-8.

        :type content_type: string
        :param content_type: Optional type of content being uploaded. Defaults
                             to ``'text/plain'``.

        :type encryption_key: str or bytes
        :param encryption_key: Optional 32 byte encryption key for
                               customer-supplied encryption.

        :type client: :class:`gcloud.storage.client.Client` or ``NoneType``
        :param client: Optional. The client to use.  If not passed, falls back
                       to the ``client`` stored on the blob's bucket.
        ru   T)rL   r   r   r7   rM   r/   N)r   r   	text_typeencoder   writer   len)r   datar7   rM   r/   r`   r   r   r    upload_from_stringW  s    

zBlob.upload_from_stringc                 C   s    | j    | j j|d dS )a  Make this blob public giving all users read access.

        :type client: :class:`gcloud.storage.client.Client` or ``NoneType``
        :param client: Optional. The client to use.  If not passed, falls back
                       to the ``client`` stored on the blob's bucket.
        rC   N)r+   allZ
grant_readsaverD   r   r   r    make_public~  s    zBlob.make_publicZcacheControlZcontentDispositionZcontentEncodingZcontentLanguagern   crc32cc                 C   s    | j d}|durt|S dS )a  Number of underlying components that make up this object.

        See: https://cloud.google.com/storage/docs/json_api/v1/objects

        :rtype: integer or ``NoneType``
        :returns: The component count (in case of a composed object) or
                  ``None`` if the property is not set locally. This property
                  will not be set on objects not created via ``compose``.
        ZcomponentCountNrv   rw   rf   )r   component_countr   r   r    r     s    zBlob.component_countc                 C   s   | j dS )a+  Retrieve the ETag for the object.

        See: http://tools.ietf.org/html/rfc2616#section-3.11 and
             https://cloud.google.com/storage/docs/json_api/v1/objects

        :rtype: string or ``NoneType``
        :returns: The blob etag or ``None`` if the property is not set locally.
        etagrv   rw   r"   r   r   r    r     s    
z	Blob.etagc                 C   s    | j d}|durt|S dS )a  Retrieve the generation for the object.

        See: https://cloud.google.com/storage/docs/json_api/v1/objects

        :rtype: integer or ``NoneType``
        :returns: The generation of the blob or ``None`` if the property
                  is not set locally.
        r:   Nr   )r   r:   r   r   r    r:     s    
zBlob.generationc                 C   s   | j dS )zRetrieve the ID for the object.

        See: https://cloud.google.com/storage/docs/json_api/v1/objects

        :rtype: string or ``NoneType``
        :returns: The ID of the blob or ``None`` if the property is not
                  set locally.
        idr   r"   r   r   r    r     s    
zBlob.idZmd5Hashc                 C   s   | j dS )a  Retrieve the media download URI for the object.

        See: https://cloud.google.com/storage/docs/json_api/v1/objects

        :rtype: string or ``NoneType``
        :returns: The media link for the blob or ``None`` if the property is
                  not set locally.
        Z	mediaLinkr   r"   r   r   r    rF   
  s    
zBlob.media_linkc                 C   s   t | jdS )a1  Retrieve arbitrary/application specific metadata for the object.

        See: https://cloud.google.com/storage/docs/json_api/v1/objects

        :rtype: dict or ``NoneType``
        :returns: The metadata associated with the blob or ``None`` if the
                  property is not set locally.
        metadatacopydeepcopyrv   rw   r"   r   r   r    r     s    
zBlob.metadatac                 C   s   |  d| dS )zUpdate arbitrary/application specific metadata for the object.

        See: https://cloud.google.com/storage/docs/json_api/v1/objects

        :type value: dict or ``NoneType``
        :param value: The blob metadata to set.
        r   N)Z_patch_propertyr%   r   r   r    r   "  s    	c                 C   s    | j d}|durt|S dS )a  Retrieve the metageneration for the object.

        See: https://cloud.google.com/storage/docs/json_api/v1/objects

        :rtype: integer or ``NoneType``
        :returns: The metageneration of the blob or ``None`` if the property
                  is not set locally.
        metagenerationNr   )r   r   r   r   r    r   -  s    
zBlob.metagenerationc                 C   s   t | jdS )a  Retrieve info about the owner of the object.

        See: https://cloud.google.com/storage/docs/json_api/v1/objects

        :rtype: dict or ``NoneType``
        :returns: Mapping of owner's role/ID. If the property is not set
                  locally, returns ``None``.
        ownerr   r"   r   r   r    r   ;  s    
z
Blob.ownerc                 C   s   | j dS )a  Retrieve the URI for the object.

        See: https://cloud.google.com/storage/docs/json_api/v1/objects

        :rtype: string or ``NoneType``
        :returns: The self link for the blob or ``None`` if the property is
                  not set locally.
        ZselfLinkr   r"   r   r   r    	self_linkG  s    
zBlob.self_linkc                 C   s    | j d}|durt|S dS )a   Size of the object, in bytes.

        See: https://cloud.google.com/storage/docs/json_api/v1/objects

        :rtype: integer or ``NoneType``
        :returns: The size of the blob or ``None`` if the property
                  is not set locally.
        r   Nr   )r   r   r   r   r    r   S  s    
z	Blob.sizec                 C   s   | j dS )a  Retrieve the storage class for the object.

        See: https://cloud.google.com/storage/docs/storage-classes
        https://cloud.google.com/storage/docs/nearline-storage
        https://cloud.google.com/storage/docs/durable-reduced-availability

        :rtype: string or ``NoneType``
        :returns: If set, one of "STANDARD", "NEARLINE", or
                  "DURABLE_REDUCED_AVAILABILITY", else ``None``.
        ZstorageClassr   r"   r   r   r    storage_classa  s    zBlob.storage_classc                 C   s    | j d}|durt|S dS )a  Retrieve the timestamp at which the object was deleted.

        See: https://cloud.google.com/storage/docs/json_api/v1/objects

        :rtype: :class:`datetime.datetime` or ``NoneType``
        :returns: Datetime object parsed from RFC3339 valid timestamp, or
                  ``None`` if the property is not set locally. If the blob has
                  not been deleted, this will never be set.
        ZtimeDeletedNrv   rw   r   r%   r   r   r    time_deletedo  s    zBlob.time_deletedc                 C   s    | j d}|durt|S dS )aM  Retrieve the timestamp at which the object was updated.

        See: https://cloud.google.com/storage/docs/json_api/v1/objects

        :rtype: :class:`datetime.datetime` or ``NoneType``
        :returns: Datetime object parsed from RFC3339 valid timestamp, or
                  ``None`` if the property is not set locally.
        rX   Nr   r%   r   r   r    rX   ~  s    
zBlob.updated)N)r3   NNNNNN)N)N)NN)NN)NN)FNNNrm   N)NNN)r   NN)N)2__name__
__module____qualname____doc__r!   r#   r   propertyr   setterstaticmethodr*   r+   r-   r.   r/   r2   r	   rB   rE   rR   r^   ra   rl   r   r   r   r   r   Zcache_controlcontent_dispositioncontent_encodingZcontent_languager7   r   r   r   r:   r   Zmd5_hashrF   r   r   r   r   r   r   r   rX   __classcell__r   r   r   r    r   2   s   






    
S


C



   
   
*  
'















r   c                   @   s*   e Zd ZdZdgZdZdZdZdZdZ	dS )r   zFaux message FBO apitools' 'configure_request'.

    Values extracted from apitools
    'samples/storage_sample/storage/storage_v1_client.py'
    z*/*NTz)/resumable/upload/storage/v1/b/{bucket}/oz/upload/storage/v1/b/{bucket}/o)
r   r   r   r   acceptmax_sizeZresumable_multipartZresumable_pathZsimple_multipartZsimple_pathr   r   r   r    r     s   r   c                   @   s   e Zd ZdZdd ZdS )r~   z.Faux builder FBO apitools' 'configure_request'c                 C   s   d|i| _ || _d| _d S )Nr   r'   )r@   Z_bucket_nameZ_relative_path)r   r,   rq   r   r   r    r     s    
z_UrlBuilder.__init__N)r   r   r   r   r   r   r   r   r    r~     s   r~   c                 C   sV   t | } t|  }t| }t|  }d|d< t||d< t||d< dS )zBuilds customer encyrption key headers

    :type key: str or bytes
    :param key: 32 byte key to build request key and hash.

    :type headers: dict
    :param headers: dict of HTTP headers being sent in request.
    ZAES256zX-Goog-Encryption-AlgorithmzX-Goog-Encryption-KeyzX-Goog-Encryption-Key-Sha256N)r   hashlibsha256digestbase64	b64encoderstripr   )keyrP   Z
sha256_keyZkey_hashZencoded_keyr   r   r    rJ     s    	rJ   )*r   r   r   r   ior   r   r   r   rZ   rV   rg   r   Zsix.moves.urllib.parser   Zgcloud._helpersr   r   r   Zgcloud.credentialsr	   Zgcloud.exceptionsr
   r   Zgcloud.storage._helpersr   r   Zgcloud.storage.aclr   Zgcloud.streaming.http_wrapperr   r   Zgcloud.streaming.transferr   r   r   r>   r   objectr   r~   rJ   r   r   r   r    <module>   sJ         a