You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2019/08/12 17:36:34 UTC

[GitHub] [airflow] mik-laj commented on a change in pull request #5770: [AIRFLOW-5162] GCS Hook Upload Method Improvement

mik-laj commented on a change in pull request #5770: [AIRFLOW-5162] GCS Hook Upload Method Improvement
URL: https://github.com/apache/airflow/pull/5770#discussion_r313042343
 
 

 ##########
 File path: airflow/contrib/hooks/gcs_hook.py
 ##########
 @@ -175,40 +175,55 @@ def download(self, bucket_name, object_name, filename=None):
 
         return blob.download_as_string()
 
-    def upload(self, bucket_name, object_name, filename,
-               mime_type='application/octet-stream', gzip=False):
+    def upload(self, bucket_name, object_name, filename=None,
+               data=None, mime_type=None, gzip=False):
         """
-        Uploads a local file to Google Cloud Storage.
-
+        Uploads a local file or file content as a string or bytes to Google Cloud Storage.
         :param bucket_name: The bucket to upload to.
         :type bucket_name: str
         :param object_name: The object name to set when uploading the local file.
         :type object_name: str
         :param filename: The local file path to the file to be uploaded.
         :type filename: str
+        :param data: The file's content as a string or bytes to be uploaded.
+        :type data: str
         :param mime_type: The MIME type to set when uploading the file.
         :type mime_type: str
-        :param gzip: Option to compress file for upload
+        :param gzip: Option to compress local file for upload
 
 Review comment:
   Why didn't you add compression support for data?
   ```
               if gzip:
                   out = StringIO.StringIO()
                   with gz.GzipFile(fileobj=out, mode="w") as f:
                       f.write(data)
                   data = out.getvalue()
   ```

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services