Omit file extensions during metadata file upload (#32)
* Upload metadata files without an extension * Display success toast on metadata updates
This commit is contained in:
parent
b9c22ea425
commit
823b8c04f5
@ -4,6 +4,7 @@
|
||||
/* eslint-disable @typescript-eslint/restrict-template-expressions */
|
||||
import { useMetadataAttributesState } from 'components/forms/MetadataAttributes.hooks'
|
||||
import { useEffect, useState } from 'react'
|
||||
import toast from 'react-hot-toast'
|
||||
|
||||
import Button from './Button'
|
||||
import { TextInput } from './forms/FormInput'
|
||||
@ -123,6 +124,7 @@ export const MetadataModal = (props: MetadataModalProps) => {
|
||||
|
||||
const editedMetadataFile = new File([metadataFileBlob], metadataFile.name, { type: 'application/json' })
|
||||
props.updateMetadata(editedMetadataFile)
|
||||
toast.success('Metadata updated successfully.')
|
||||
console.log(editedMetadataFile)
|
||||
}
|
||||
|
||||
|
@ -171,9 +171,13 @@ const CollectionCreationPage: NextPage = () => {
|
||||
const metadataFileBlob = new Blob([JSON.stringify(data)], {
|
||||
type: 'application/json',
|
||||
})
|
||||
const updatedMetadataFile = new File([metadataFileBlob], uploadDetails.metadataFiles[i].name, {
|
||||
type: 'application/json',
|
||||
})
|
||||
const updatedMetadataFile = new File(
|
||||
[metadataFileBlob],
|
||||
uploadDetails.metadataFiles[i].name.substring(0, uploadDetails.metadataFiles[i].name.lastIndexOf('.')),
|
||||
{
|
||||
type: 'application/json',
|
||||
},
|
||||
)
|
||||
fileArray.push(updatedMetadataFile)
|
||||
}
|
||||
reader.onloadend = () => {
|
||||
@ -199,21 +203,21 @@ const CollectionCreationPage: NextPage = () => {
|
||||
|
||||
const checkUploadDetails = () => {
|
||||
if (!uploadDetails) {
|
||||
throw new Error('Please upload asset and metadata')
|
||||
throw new Error('Please select assets and metadata')
|
||||
}
|
||||
if (uploadDetails.assetFiles.length === 0) {
|
||||
throw new Error('Please upload assets')
|
||||
throw new Error('Please select the assets')
|
||||
}
|
||||
if (uploadDetails.metadataFiles.length === 0) {
|
||||
throw new Error('Please upload metadatas')
|
||||
throw new Error('Please select the metadata files')
|
||||
}
|
||||
compareFileArrays(uploadDetails.assetFiles, uploadDetails.metadataFiles)
|
||||
if (uploadDetails.uploadService === 'nft-storage') {
|
||||
if (uploadDetails.nftStorageApiKey === '') {
|
||||
throw new Error('Please enter NFT Storage api key')
|
||||
throw new Error('Please enter a valid NFT Storage API key')
|
||||
}
|
||||
} else if (uploadDetails.pinataApiKey === '' || uploadDetails.pinataSecretKey === '') {
|
||||
throw new Error('Please enter Pinata api key and secret key')
|
||||
throw new Error('Please enter Pinata API and secret keys')
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user