I am using ibm-cos-sdk but I can able to store text files only, but I want to upload images and pdf files. Can someone help me out of that?
Asked
Active
Viewed 1,383 times
1 Answers
0
The IBM Cloud solution tutorial on how to apply end to end security to a cloud app features a file sharing app. The files are stored in COS, the app built using Node.js. See these lines of code for the example.
// upload to COS
await cos.upload({
Bucket: COS_BUCKET_NAME,
Key: `${fileDetails.userId}/${fileDetails.id}/${fileDetails.name}`,
Body: fs.createReadStream(file.path),
ContentType: fileDetails.type,
}).promise();
The snippet uses the mentioned ibm-cos-sdk with the S3 interface. I have used the app and code to upload images and PDFs.

data_henrik
- 16,724
- 2
- 28
- 49