Using filename from file metadata

This commit is contained in:
Chris Troutner
2024-04-09 22:00:58 -07:00
parent 3c9bbb097e
commit b5c7e2efb3
+6 -2
View File
@@ -54,7 +54,7 @@ class IpfsUseCases {
// throw new Error('File has not been pinned. Not available.') // throw new Error('File has not been pinned. Not available.')
// } // }
await this.getCidMetadata({ cid }) const filename = await this.getCidMetadata({ cid })
const helia = this.adapters.ipfs.ipfs const helia = this.adapters.ipfs.ipfs
@@ -74,7 +74,7 @@ class IpfsUseCases {
} }
const readStream = bufferToStream(fileBuf) const readStream = bufferToStream(fileBuf)
const filename = 'test.jpg' // const filename = 'test.jpg'
return { filename, readStream } return { filename, readStream }
} catch (err) { } catch (err) {
@@ -95,6 +95,10 @@ class IpfsUseCases {
const metadata = await ipfsFiles.getFileMetadata({ cid }) const metadata = await ipfsFiles.getFileMetadata({ cid })
console.log('getCidMetadata() metadata: ', metadata) console.log('getCidMetadata() metadata: ', metadata)
const filename = metadata.fileMetadata.filename
return filename
} catch (err) { } catch (err) {
console.error('Error in getCidMetadata(): ', err) console.error('Error in getCidMetadata(): ', err)
throw err throw err