Skip to content

Allow reading only n tail bytes from a file #420

Description

@stephenplusplus

Carrying on from #415, a user can specify a start and end range to read from a remote file. The JSON API also allows reading n tail bytes from a file, e.g. range=-100 would be the last 100 bytes. Our API currently looks like:

file.createReadStream({ start: 0, end: 10 })

We could allow specifying a range in another way:

file.createReadStream({ range: "0-10" })

Which would open the doors for:

file.createReadStream({ range: "-100" })

Definitely open to other ideas of how we can support ranges of both types: "start and end" and "end offset".

Note: start and end was added to match the native fs module's createReadStream's arguments, which behaves the same was currently as ours.

Activity

  1. added this to the Storage Future milestone on Mar 3, 2015
  2. changed the title [-]Allow readonly only n tail bytes from a file[/-] [+]Allow reading only n tail bytes from a file[/+] on Mar 3, 2015
  3. ryanseys commented on Mar 3, 2015

    @ryanseys
    Contributor

    Another idea I'm not too attached to but figured I'd throw it out. What about:

    file.createReadStream({ tail: 10 })

    This would override or be always overridden by start/end. Problems include introducing another parameter, parameters that void other parameters, but benefits are it's clear in its purpose.

  4. stephenplusplus commented on Jul 1, 2015

    @stephenplusplus
    ContributorAuthor

    How about just allowing:

    file.createReadStream({ end: -10 })

    and adding documentation to explain that's reading -10 tail bytes?

  5. jgeewax commented on Jul 1, 2015

    @jgeewax
    Contributor

    I'm 👍 to end: -10 (the same way in CSS you can do right: -10px for example). Definitely would rather this than adding a new parameter... But you guys are the experts.

  6. stephenplusplus commented on Jul 1, 2015

    @stephenplusplus
    ContributorAuthor

    Cool cool. Let's try it out and if we find the community hates it, we can try again!

  7. 26 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

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions