GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Unable to upload empty file? · Issue #3685 · googleapis/google-cloud-python

Unable to upload empty file? #3685

New issue
Copy link
New issue
Copy link
Closed
googleapis/google-resumable-media-python
#25
googleapis/google-resumable-media-python#25
Closed
Unable to upload empty file?#3685
googleapis/google-resumable-media-python
#25
Copy link
Assignees
dhermes
Labels
api: storageIssues related to the Cloud Storage API.priority: p2Moderately-important priority. Fix may not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

Description

@danqing
danqing
opened on Jul 27, 2017
Issue body actions

macOS 10.12.6, Python 3.6.2, google-cloud-storage 1.2.0.

It seems that if a file is empty, I cannot upload it:

blob = storage.Blob(dest_filename, bucket, chunk_size=262144)
blob.upload_from_filename(src_filename, content_type=content_type)

Error:

File "storage.py", line 88, in upload_from_file
    blob.upload_from_filename(src_filename, content_type=content_type)
File "app/env/lib/python3.6/site-packages/google/cloud/storage/blob.py", line 934, in upload_from_filename
    size=total_bytes)
File "app/env/lib/python3.6/site-packages/google/cloud/storage/blob.py", line 891, in upload_from_file
    client, file_obj, content_type, size, num_retries)
File "app/env/lib/python3.6/site-packages/google/cloud/storage/blob.py", line 818, in _do_upload
    client, stream, content_type, size, num_retries)
File "app/env/lib/python3.6/site-packages/google/cloud/storage/blob.py", line 771, in _do_resumable_upload
    response = upload.transmit_next_chunk(transport)
File "app/env/lib/python3.6/site-packages/google/resumable_media/requests/upload.py", line 392, in transmit_next_chunk
    method, url, payload, headers = self._prepare_request()
File "app/env/lib/python3.6/site-packages/google/resumable_media/_upload.py", line 531, in _prepare_request
    self._stream, self._chunk_size, self._total_bytes)
File "app/env/lib/python3.6/site-packages/google/resumable_media/_upload.py", line 805, in get_next_chunk
    u'Stream is already exhausted. There is no content remaining.')
ValueError: Stream is already exhausted. There is no content remaining.

When uploading a folder, it'd be ideal if I don't need to check whether a file is empty before uploading. Or am I doing something wrong?

Thanks!

Activity

  1. tseaver
    added
    api: storageIssues related to the Cloud Storage API.
    on Jul 27, 2017
  2. tseaver commented on Jul 27, 2017

    @tseaver
    tseaver
    on Jul 27, 2017
    Contributor
    More actions

    @danqing Thanks for the report! I believe this is a bug in https://github.com/GoogleCloudPlatform/google-resumable-media-python/, maybe due to the problematic behavior of read (returning an empty string at EOF).

    @dhermes Can you clarify?

  3. danqing commented on Jul 28, 2017

    @danqing
    danqing
    on Jul 28, 2017
    Author
    More actions

    Friendly ping @dhermes :)

  4. lukesneeringer
    added
    priority: p2Moderately-important priority. Fix may not be included in next release.
    type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.
    on Aug 7, 2017
  5. lukesneeringer
    added a commit that references this issue on Aug 7, 2017

    Allow empty files to be uploaded.

    This issue will close once commit acb1468 is merged into the 'main' branch.
    acb1468
  6. lukesneeringer commented on Aug 7, 2017

    @lukesneeringer
    lukesneeringer
    on Aug 7, 2017
    Contributor
    More actions

    @dhermes I filed googleapis/google-resumable-media-python#25 to fix this, but need guidance on whether it is correct.

  7. lukesneeringer
    added
    status: in review
    on Aug 7, 2017
  8. dhermes commented on Aug 7, 2017

    @dhermes
    dhermes
    on Aug 7, 2017
    Contributor
    More actions

    I believe googleapis/google-resumable-media-python#25 is ready to merge.

    @danqing The fix may not lead to immedate releases of google-resumable-media==0.2.3 (and possibly google-cloud-storage==1.3.1), but in the meanwhile, if you don't set the chunk size, then a MultipartUpload will be used, which has no issue sending an empty file.

  9. dhermes
    closed this as completedin google-resumable-media-python#25on Aug 7, 2017
  10. dhermes
    added a commit that references this issue on Aug 7, 2017

    Allow empty files to be uploaded.

    This issue will close once commit 0e4fa01 is merged into the 'main' branch.
    0e4fa01
  11. danqing commented on Aug 7, 2017

    @danqing
    danqing
    on Aug 7, 2017
    Author
    More actions

    I see. Thanks @dhermes ! I've already implemented a workaround - will wait until 0.2.3 to get rid of it :)

  12. dhermes commented on Aug 7, 2017

    @dhermes
    dhermes
    on Aug 7, 2017
    Contributor
    More actions

    Closing this based on https://github.com/GoogleCloudPlatform/google-resumable-media-python/releases/tag/0.2.3

  13. dhermes commented on Aug 7, 2017

    @dhermes
    dhermes
    on Aug 7, 2017
    Contributor
    More actions

    Blerg, the release build https://circleci.com/gh/GoogleCloudPlatform/google-resumable-media-python/189 collided with a different build https://circleci.com/gh/GoogleCloudPlatform/google-resumable-media-python/188 and made some flaky failures.

    Hopefully https://circleci.com/gh/GoogleCloudPlatform/google-resumable-media-python/190 will actually succeed and push the release to PyPI

    Reacted by jeffjohnsunil
    Reacted by jeffjohnsunil
    Reacted by Danqing Liu and jeffjohnsunil
    Reacted by jeffjohnsunil
    Reacted by jeffjohnsunil
    Reacted by jeffjohnsunil
  14. dhermes commented on Aug 7, 2017

    @dhermes
    dhermes
    on Aug 7, 2017
    Contributor
    More actions

    https://pypi.org/project/google-cloud-storage/1.3.1/ exists now (in addition to https://pypi.org/project/google-resumable-media/0.2.3/)

    Reacted by Danqing Liu
  15. JustinBeckwith
    assigned
    dhermes
    on Feb 1, 2021
  16. parthea
    added a commit that references this issue on Sep 22, 2023

    chore: move samples from python-docs-sample (#33)

    69c4425
  17. parthea
    added a commit that references this issue on Mar 2, 2026

    Allow empty files to be uploaded.

    This issue will close once commit ed1fda2 is merged into the 'main' branch.
    ed1fda2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @dhermes
    dhermes

Labels

api: storageIssues related to the Cloud Storage API.priority: p2Moderately-important priority. Fix may not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402775 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.