node.jsopenstackobject-storageovhpkgcloud

OVH Object Storage, nothing happens when I try to upload large file (more than 100 Ko)


I try to upload files with OVH object storage. But I have three different behavior according to the heavy file.

This is my code:

  var client = require('pkgcloud').storage.createClient({
    provider: 'openstack',
    username: myusername,
    password: mypassword,
    region: 'GRA',
    authUrl: 'https://auth.cloud.ovh.net/'
  });

  const fsReadStream = fs.createReadStream(path.resolve(__dirname, fileLocation))

  let writeStream = client.upload({
    container: myOvhStorageContainer,
    remote: 'fileName.jpg',
  });

  writeStream.on('error', function (err) {

    console.log(err)
  });

  writeStream.on('success', async function (file) {
    console.log(file)
  });

  fsReadStream.on('open', function () {
    console.log('open!!')

    fsReadStream.pipe(writeStream);
  });

Solution

  • The problem comes from a bug in pkgcloud in how it streams files for OpenStack Storage.

    The solution is exposed, and a fix is proposed, in https://github.com/pkgcloud/pkgcloud/pull/673

    There are forks of pkgcloud that include the proposed fix, and they can be used while waiting for the fix to be officially accepted:

    To use such a repository in your project/application, edit your package.json to modify the dependencies like this:

    "dependencies": {
        …
        "pkgcloud": "https://github.com/madarche/pkgcloud.git#fe2701eb6eb984e3d067d5df7610ca0751528dbd",
        …
      },
    

    You can also simply create your own fork of pkgclould, so you don't have to trust a random Git repository.