Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

File#save should support Readable / AsyncIterable data #2202

Closed
matthieusieben opened this issue May 26, 2023 · 0 comments · Fixed by #2203
Closed

File#save should support Readable / AsyncIterable data #2202

matthieusieben opened this issue May 26, 2023 · 0 comments · Fixed by #2203
Assignees
Labels
api: storage Issues related to the googleapis/nodejs-storage API. priority: p3 Desirable enhancement or fix. May not be included in next release. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.

Comments

@matthieusieben
Copy link
Contributor

Is your feature request related to a problem? Please describe.

I have a small utility function in my codebase that looks like this:

const { pipeline } = require('node:stream/promises')

async function write(file, data, type, metadata = undefined) {
  if (Buffer.isBuffer(data) || typeof data === 'string') {
    await file.save(data, {
      timeout: 9e3,
      contentType: type,
      resumable: false,
      metadata: { metadata },
    })
  } else {
    const writable = file.createWriteStream({
      timeout: 9e3,
      gzip: true,
      contentType: type,
      resumable: false,
      metadata: { metadata },
    })

    await pipeline(data, writable)
  }
}

And it seems this could easily be implemented in the lib itself.

Describe the solution you'd like

I would like File#save 's data argument to support AsyncIterable (Readable)

Describe alternatives you've considered

see code example above

@matthieusieben matthieusieben added priority: p3 Desirable enhancement or fix. May not be included in next release. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design. labels May 26, 2023
@product-auto-label product-auto-label bot added the api: storage Issues related to the googleapis/nodejs-storage API. label May 26, 2023
matthieusieben added a commit to matthieusieben/nodejs-storage that referenced this issue May 26, 2023
matthieusieben added a commit to matthieusieben/nodejs-storage that referenced this issue Jun 8, 2023
matthieusieben added a commit to matthieusieben/nodejs-storage that referenced this issue Jul 11, 2023
matthieusieben added a commit to matthieusieben/nodejs-storage that referenced this issue Jul 13, 2023
matthieusieben added a commit to matthieusieben/nodejs-storage that referenced this issue Jul 14, 2023
matthieusieben added a commit to matthieusieben/nodejs-storage that referenced this issue Jul 14, 2023
matthieusieben added a commit to matthieusieben/nodejs-storage that referenced this issue Jul 14, 2023
ddelgrosso1 added a commit that referenced this issue Aug 11, 2023
ddelgrosso1 added a commit that referenced this issue Aug 11, 2023
* feat: support iterables in file#save (#2202) (#2203)

* Revert "feat: support iterables in file#save (#2202) (#2203)" (#2270)

This reverts commit c0d9d58.

* Revert "Revert "feat: support iterables in file#save (#2202) (#2203)" (#2270)"

This reverts commit 49327ff.

---------

Co-authored-by: Matthieu <[email protected]>
ddelgrosso1 pushed a commit to ddelgrosso1/nodejs-storage that referenced this issue Aug 11, 2023
ddelgrosso1 added a commit to ddelgrosso1/nodejs-storage that referenced this issue Aug 11, 2023
ddelgrosso1 added a commit to ddelgrosso1/nodejs-storage that referenced this issue Aug 11, 2023
…"" (googleapis#2271)

* feat: support iterables in file#save (googleapis#2202) (googleapis#2203)

* Revert "feat: support iterables in file#save (googleapis#2202) (googleapis#2203)" (googleapis#2270)

This reverts commit c0d9d58.

* Revert "Revert "feat: support iterables in file#save (googleapis#2202) (googleapis#2203)" (googleapis#2270)"

This reverts commit 49327ff.

---------

Co-authored-by: Matthieu <[email protected]>
ddelgrosso1 pushed a commit to ddelgrosso1/nodejs-storage that referenced this issue Aug 11, 2023
ddelgrosso1 added a commit to ddelgrosso1/nodejs-storage that referenced this issue Aug 11, 2023
ddelgrosso1 added a commit to ddelgrosso1/nodejs-storage that referenced this issue Aug 11, 2023
…"" (googleapis#2271)

* feat: support iterables in file#save (googleapis#2202) (googleapis#2203)

* Revert "feat: support iterables in file#save (googleapis#2202) (googleapis#2203)" (googleapis#2270)

This reverts commit c0d9d58.

* Revert "Revert "feat: support iterables in file#save (googleapis#2202) (googleapis#2203)" (googleapis#2270)"

This reverts commit 49327ff.

---------

Co-authored-by: Matthieu <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: storage Issues related to the googleapis/nodejs-storage API. priority: p3 Desirable enhancement or fix. May not be included in next release. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants