Skip to content

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
    }
  })
})

@pkg-pr-new
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

@cloudflare-workers-and-pages
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

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.

2 participants