1

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?

habercde
  • 161
  • 1
  • 10

1 Answers1

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