8000 feat(blob)!: change API for consistency by atinux · Pull Request #187 · nuxt-hub/core · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

feat(blob)!: change API for consistency #187

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

Merged
merged 11 commits into from
Jun 27, 2024
Merged

feat(blob)!: change API for consistency #187

merged 11 commits into from
Jun 27, 2024

Conversation

atinux
Copy link
Contributor
@atinux atinux commented Jun 27, 2024

This brings two breaking changes for hubBlob()

Custom Metadata

As we get the custom metadata in the customMetadata object, it makes sense to define them in the key as well.

Before:

hubBlob().put(file.name, file, {
  addRandomSuffix: true,
  hello: 'world'
})
/*
{
  contentType: 'image/jped',
  pathname: 'something-87652rfg.jpg',
  size: 154451,
  uploadedAt:  '2024-06-21T00:57:41.740Z',
  customMetadata: {
    hello: 'world'
  }
}
*/

After:

hubBlob().put(file.name, file, {
  addRandomSuffix: true,
  customMetadata: {
    hello: 'world'
  }
})
/*
{
  contentType: 'image/jped',
  pathname: 'something-87652rfg.jpg',
  size: 154451,
  uploadedAt:  '2024-06-21T00:57:41.740Z',
  customMetadata: {
    hello: 'world'
  }
}
*/

handleUpload

Before, we could give at the same level the options of put(), ensure() and handleUpload(), making it a bit confusing.

Now you need to set the options with the command prefix:

Before:

export default eventHandler(async (event) => {
  return hubBlob().handleUpload(event, {
    multiple: false,
    contentType: ['image/jpeg', 'images/png'],
    addRandomSuffix: true
  })
})

After:

export default eventHandler(async (event) => {
  return hubBlob().handleUpload(event, {
    multiple: false,
    ensure: {
      contentType: ['image/jpeg', 'images/png'],
    },
    put: {
      addRandomSuffix: true
    }
  })
})

Copy link
pkg-pr-new bot commented Jun 27, 2024

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

commit: 2d86b08

@nuxthub/core

npm i https://pkg.pr.new/nuxt-hub/core/@nuxthub/core@187


templates

Copy link
cloudflare-workers-and-pages bot commented Jun 27, 2024

Deploying nuxthub-docs with  Cloudflare Pages  Cloudflare Pages

Latest commit: 9f18a93
Status: ✅  Deploy successful!
Preview URL: https://aa3f57cb.nuxthub-module.pages.dev
Branch Preview URL: https://feat-blob-improvements.nuxthub-module.pages.dev

View logs

@atinux atinux merged commit 6705b8b into main Jun 27, 2024
5 checks passed
@atinux atinux deleted the feat/blob-improvements branch June 27, 2024 14:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant
0