-
Notifications
You must be signed in to change notification settings - Fork 41
Closed
Description
This is how I'm using the library, and for this case it works fine. It creates a new file with a random suffix.
const asset: Asset = await assetsService.upload({
file: imageBuffer,
fileName: "avatar.jpeg",
folder: "/avatars",
}).catch(e=> {
Logger.error(e);
});But I want to replace the existing file when a new file of the same name is uploaded. So, I tried used the useUniqueFileName option and set it to false. But whenever the useUniqueFileName is set, the library throws the following error:
TypeError [ERR_INVALID_ARG_TYPE]: The first argument must be of type string or an instance of Buffer. Received type boolean (false)
at write_ (_http_outgoing.js:653:11)
at ClientRequest.write (_http_outgoing.js:621:15)
at Request.write (/app/node_modules/request/request.js:1494:27)
at FormData.ondata (internal/streams/legacy.js:19:31)
at FormData.emit (events.js:315:20)
at FormData.CombinedStream.write (/app/node_modules/combined-stream/lib/combined_stream.js:138:8)
at FormData.CombinedStream._pipeNext (/app/node_modules/combined-stream/lib/combined_stream.js:126:8)
at FormData.CombinedStream._realGetNext (/app/node_modules/combined-stream/lib/combined_stream.js:99:10)
at FormData.CombinedStream._getNext (/app/node_modules/combined-stream/lib/combined_stream.js:82:12)
at FormData.CombinedStream.resume (/app/node_modules/combined-stream/lib/combined_stream.js:154:10)
at FormData.CombinedStream.pipe (/app/node_modules/combined-stream/lib/combined_stream.js:66:8)
at end (/app/node_modules/request/request.js:533:22)
at FormData.<anonymous> (/app/node_modules/request/request.js:575:9)
at processTicksAndRejections (internal/process/task_queues.js:79:11) {
code: 'ERR_INVALID_ARG_TYPE'
}The same error is thrown even if useUniqueFileName is set to true:
TypeError [ERR_INVALID_ARG_TYPE]: The first argument must be of type string or an instance of Buffer. Received type boolean (true)
at write_ (_http_outgoing.js:653:11)
at ClientRequest.write (_http_outgoing.js:621:15)
at Request.write (/app/node_modules/request/request.js:1494:27)
at FormData.ondata (internal/streams/legacy.js:19:31)
at FormData.emit (events.js:315:20)
at FormData.CombinedStream.write (/app/node_modules/combined-stream/lib/combined_stream.js:138:8)
at FormData.CombinedStream._pipeNext (/app/node_modules/combined-stream/lib/combined_stream.js:126:8)
at FormData.CombinedStream._realGetNext (/app/node_modules/combined-stream/lib/combined_stream.js:99:10)
at FormData.CombinedStream._getNext (/app/node_modules/combined-stream/lib/combined_stream.js:82:12)
at FormData.CombinedStream.resume (/app/node_modules/combined-stream/lib/combined_stream.js:154:10)
at FormData.CombinedStream.pipe (/app/node_modules/combined-stream/lib/combined_stream.js:66:8)
at end (/app/node_modules/request/request.js:533:22)
at FormData.<anonymous> (/app/node_modules/request/request.js:575:9)
at processTicksAndRejections (internal/process/task_queues.js:79:11) {
code: 'ERR_INVALID_ARG_TYPE'
}Metadata
Metadata
Assignees
Labels
No labels