OVH对象存储,当我尝试上传大文件(超过100 Ko)时,什么都不会发生



我尝试使用OVH对象存储上传文件。但我有三种不同的行为根据沉重的文件。

  • 重量文件小于100Ko,一切正常

  • 对于一个超过100Ko的权重文件,我有这个错误:Error: write after end,但该文件被上传到ovh对象存储上

  • 对于一个超过250Ko的权重文件,什么都没有发生,文件也没有上传。fs ReadStream已打开,但通过管道传输的写入流(与读取流一起(未完成。

这是我的代码:

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);
});

问题来自pkgcloud中为OpenStack Storage流式传输文件的错误。

解决方案在中公开,并提出了修复方案https://github.com/pkgcloud/pkgcloud/pull/673

pkgcloud的分支包括所提出的修复程序,它们可以在等待修复程序被正式接受时使用:

  • https://github.com/madarche/pkgcloud/
  • https://github.com/StartupFlow/pkgcloud/tree/fix_write_after_end

要在项目/应用程序中使用这样的存储库,请编辑package.json以修改dependencies,如下所示:

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

您也可以简单地创建自己的pkgclould分支,这样您就不必信任随机的Git存储库。

最新更新