originalFilename is Lost when Uploading Images via Node

1 replies
Last updated: Aug 25, 2020
Morning, my upgrade to
went smoothly, some really nice tweaks to the UI. I’m especially happy that a readonly block now has a proper state where it can’t be edited! 👍
I’m uploading images via node, but the
is lost in this process and default to the name sanity gives the asset. Is there a way I can set this manually using
, or is this a bug?

const uploadImage = async (src) => {
  const theFetch = await fetch(src)
  const theBuffer = await theFetch.buffer()
  const imageAsset = await sanityClient.assets.upload('image', theBuffer)
  return imageAsset

Aug 25, 2020, 10:32 AM
Okay found the answer here using the filename option… https://www.sanity.io/docs/assets I thought setting a filename would set the filename in the
, not the
silly me. 🙃
Aug 25, 2020, 10:46 AM

Sanity.io – build remarkable experiences at scale

Sanity is a customizable solution that treats content as data to power your digital business. Free to get started, and pay-as-you-go on all plans.

Categorized in