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