I try to upload files with OVH object storage. But I have three different behavior according to the heavy file.
With a weight file which less than 100Ko, everything is ok
With a weight file which more than 100Ko, I have this error:
Error: write after end
, but the file is uploaded on ovh object storageWith a weight file which more than 250Ko, nothing happens, and the file is not uploaded. The fs ReadStream is open, but the write stream piped (with the read stream) not finish.
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);
});