Skip to content

Commit

Permalink
fix: avoid uploading gif files twice (#350)
Browse files Browse the repository at this point in the history
Co-authored-by: melMass <[email protected]>
Co-authored-by: Mel Massadian <[email protected]>

- Closes #278
  • Loading branch information
Zir0h authored Oct 27, 2023
1 parent 89af49d commit 4102c3b
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/data/ipfs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,19 @@ export const prepareFile = async ({

// upload thumbnail image
let thumbnailUri = IPFS_DEFAULT_THUMBNAIL_URI
if (thumbnail) {
if (thumbnail && thumbnail.file?.type === 'image/gif') {
console.debug(
"GIF format detected, we will use the artifact's cid as the thumbnail to avoid uploading twice"
)
thumbnailUri = `${uri}`
if (thumbnail?.format) {
const format = JSON.parse(JSON.stringify(thumbnail.format))
format.uri = thumbnailUri
format.fileName = `thumbnail_${format.fileName}`
formats.push(format)
console.debug('thumbnail format', format)
}
} else if (thumbnail) {
const thumbnailCid = await uploadFileToIPFSProxy({
blob: new Blob([thumbnail.buffer]),
path: `thumbnail_${
Expand Down

0 comments on commit 4102c3b

Please sign in to comment.