1

Hi I want to make an app which can upload files to bluemix-object-storage using pkgcloud.

Right now I am using multer to get the files in the server.

But pkgcloud.upload() is accept readable stream, whereas req.files is not readable streams.

  var readStream = fs.createReadStream('a-file.txt');
  var writeStream = client.upload({
    container: 'a-container',
    remote: 'remote-file-name.txt'
  });

  writeStream.on('error', function(err) {
    // handle your error case
  });

  writeStream.on('success', function(file) {
    // success, file will be a File model
  });

  **readStream.pipe(writeStream);**

How can I upload the file using multer + pkgcloud, without have to save the file to the temporary directory (without using fs)?

ralphearle
  • 1,696
  • 13
  • 18
Kim
  • 1,081
  • 2
  • 12
  • 17

0 Answers0