@@ -101,6 +101,36 @@ def document_from_url(self, gcs_url,
101101 :class:`Document` constructor.
102102
103103 :rtype: :class:`Document`
104- :returns: A plain-text document bound to this client.
104+ :returns: A document bound to this client.
105105 """
106106 return Document (self , gcs_url = gcs_url , doc_type = doc_type , ** kwargs )
107+
108+
109+ def document_from_blob (self , bucket_name , blob_name ,
110+ doc_type = Document .PLAIN_TEXT , ** kwargs ):
111+ """Create a Cloud Storage document bound to this client.
112+
113+ :type bucket_name: str
114+ :param bucket_name: The name of the bucket that contains the
115+ document text.
116+
117+ :type blob_name: str
118+ :param blob_name: The name of the blob (within the bucket) that
119+ contains document text.
120+
121+ :type doc_type: str
122+ :param doc_type: (Optional) The type of text in the document.
123+ Defaults to plain text. Can also be specified
124+ as HTML via :attr:`~.Document.HTML`.
125+
126+ :type kwargs: dict
127+ :param kwargs: Remaining keyword arguments to be passed along to the
128+ :class:`Document` constructor.
129+
130+ :rtype: :class:`Document`
131+ :returns: A document bound to this client.
132+ """
133+ # NOTE: We assume that the bucket and blob name don't
134+ # need to be URL-encoded.
135+ gcs_url = 'gs://%s/%s' % (bucket_name , blob_name )
136+ return self .document_from_url (gcs_url , doc_type = doc_type , ** kwargs )
0 commit comments