上传文件
Upload file(s) to MCS using the MCS SDK
require('dotenv').config()
const { mcsSDK } = require('js-mcs-sdk')
const fs = require('fs') // used to read files
// set up js-mcs-sdk
const mcs = new mcsSDK({
privateKey: process.env.PRIVATE_KEY,
rpcUrl: process.env.RPC_URL,
})
async function main() {
// ENTER PARAMETERS
const PATH_1 = ''
const PATH_2 = ''
const fileArray = [
{ fileName: 'file1', file: fs.createReadStream(PATH_1) },
{ fileName: 'file2', file: fs.createReadStream(PATH_2) },
]
//optional, showing default options
const options = {
delay: 1000, // delay between upload API calls for each file. May need to be raised for larger files
duration: 525, // the number of days to store the file on the Filecoin network.
fileType: 0, // set to 1 for nft metadata files. type 1 files will not show on the UI.
}
const uploadResponses = await mcs.upload(fileArray, options)
console.log(uploadResponses)
}
main()Parameters
Return
Last updated