将zip文件上传到blob-storage [英] upload a zip file to blob-storage

查看:232
本文介绍了将zip文件上传到blob-storage的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一种上传解决方案的方法 我 zip文件,以便将其发送到azure blob存储.目前这就是我所拥有的

I am searching for a solution to upload my zip file in order to send it through to azure blob-storage. Currently this is what I have

async _uploadStreamToBlob(zipFile, fileName) {
    const blobService = await this.__self.blobStorage.createBlobService(this.__self.blobStorageConnectionString);
    const containerName = this.__self.blobContainerName;

    const sourceFilePath = `${path.resolve(zipFile)}`;
    const streamSource = fs.createReadStream(sourceFilePath);
    return new Promise((resolve, reject) => {
        streamSource.pipe(blobService.createWriteStreamToBlockBlob(containerName, fileName, error => {
            if (error) {
                reject(error);
            } else {
                resolve({ message: `Upload of '${fileName}' complete` });
            }
        }));
    });
};

自从fileStream向管道中馈入零字节,从而成功上传了0字节的zipFile. 到Blob存储中.如何将zipFile流式传输到azureWriteStream上?或者如何从zipFile中获取字节(保留内容)?如果还有其他方法可以做到这一点,我全神贯注.谢谢

This clearly does not work as I've tested otherwise since the fileStream feeds zero bytes into the pipe, resulting in a succesful upload of a 0 byte zipFile into the blob-storage. How do I stream the zipFile onto the azureWriteStream? Or how do I get the bytes off of the zipFile(preserving the contents)? If there is any other way to achieving this, I am all ears. Thanks

ps:已尝试 最初是createBlockBlobFromLocalFile 但同样的问题,因此尝试将其流式传输,但没有骰子.

ps: tried createBlockBlobFromLocalFile initially but same issue so tried streaming it in, but no dice.

推荐答案

您可以尝试使用 这个

You can try to upload using this


这篇关于将zip文件上传到blob-storage的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆