def _callFUT(self, *args, **kwargs): from google.cloud.credentials import generate_signed_url return generate_signed_url(*args, **kwargs)
def generate_signed_url(self, expiration, method='GET', content_type=None, generation=None, response_disposition=None, response_type=None, client=None, credentials=None): """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/\ google-cloud-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:`~google.cloud.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. """ resource = '/{bucket_name}/{quoted_name}'.format( bucket_name=self.bucket.name, quoted_name=quote(self.name, safe='')) if credentials is None: client = self._require_client(client) credentials = client._base_connection.credentials return generate_signed_url(credentials, resource=resource, api_access_endpoint=_API_ACCESS_ENDPOINT, expiration=expiration, method=method, content_type=content_type, response_type=response_type, response_disposition=response_disposition, generation=generation)
def generate_signed_url(self, expiration, method='GET', content_type=None, generation=None, response_disposition=None, response_type=None, client=None, credentials=None): """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/\ google-cloud-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:`~google.cloud.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. """ resource = '/{bucket_name}/{quoted_name}'.format( bucket_name=self.bucket.name, quoted_name=quote(self.name, safe='')) if credentials is None: client = self._require_client(client) credentials = client._connection.credentials return generate_signed_url( credentials, resource=resource, api_access_endpoint=_API_ACCESS_ENDPOINT, expiration=expiration, method=method, content_type=content_type, response_type=response_type, response_disposition=response_disposition, generation=generation)