Skip to content

Found a bug in file.js gcloud storage #415

Description

@Marc477

I found a bug in file.js at line 318

Range: 'bytes=' + [options.start || '', options.end || ''].join('-')

If I I use a read stream with start and end, it wont work if start = 0
aFile.createReadStream({start: 0, end: 123}).pipe(res);

Here the header Range will be set to "bytes:-123" but google storage will return nothing, the header should be set to "bytes:0-123" to get valid data from gcloud storage.

Make sure you set nothing in the header Range only if options.start is UNDEFINED but not if it is equal to 0

Activity

  1. added
    type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.
    api: storageIssues related to the Cloud Storage API.
    on Feb 27, 2015
  2. stephenplusplus commented on Feb 28, 2015

    @stephenplusplus
    Contributor

    Yeah, looks like that gets the last x bytes, where I thought 0 was implied. We can just fix the bug and call it done, though I would rather default to 0 if not specified. We would shut out the ability for a user to read the tail bytes, but maybe we can come up with another way to do that.

  3. ryanseys commented on Feb 28, 2015

    @ryanseys
    Contributor

    I think it's understandable once you get past that initial assumption. Range requests are a little out of the ordinary anyway, so giving the users flexibility here is probably better and worth the couple extra sentences of documentation to describe the different cases. No reason to overcomplicate with "another way" when this way works just fine with a sprinkle of documentation. :)

  4. ryanseys commented on Mar 1, 2015

    @ryanseys
    Contributor

    I've changed my mind on this considering the terminology we are using start and end. I've updated the PR to reflect this. You'll no longer be able to "tail" the objects contents using just the end value. We'll have to find a way to support this functionality in the future.

  5. 15 remaining items

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

🚨This issue needs some love.api: storageIssues related to the Cloud Storage API.triage meI really want to be triaged.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