【问题标题】:Javascript using msgreader's attachment Extraction & upload to Azure blob storageJavascript 使用 msgreader 的附件提取并上传到 Azure blob 存储
【发布时间】:2020-03-09 01:40:12
【问题描述】:

我一直在使用 MSG Reader 将电子邮件和附件提取到带有 Javascript 的系统中。

我想将提取的附件上传到 Azure 存储 Blob。

它上传,但文件不断损坏。

这是我目前所拥有的:

 fileReader.onload = function (evt) {
    var buffer = evt.target.result;
    var msgReader = new MSGReader(buffer);
    var fileData = msgReader.getFileData();
    if (!fileData.error) {
        jQuery.map(fileData.attachments, function (attachment, i) {
            var file = msgReader.getAttachment(i);
            extension = (/[.]/.exec(attachment.fileName)) ? /[^.]+$/.exec(attachment.fileName) : '';
            var blobOptions;
            switch(extension[0]) {
                case 'pdf':
                    blobOptions = {blobHTTPHeaders: { blobContentType: 'application/pdf'}};
                    blobtype = 'application/pdf';
                    break;
                default:
                    blobOptions = {blobHTTPHeaders: { blobContentType: 'application/octet-stream' }};
                    blobtype = 'application/octet-stream';
            }
            const blockBlobURL = azblob.BlockBlobURL.fromContainerURL(containerURL, attachment.fileName);
            azblob.uploadBrowserDataToBlockBlob(azblob.Aborter.none, new File([JSON.stringify(file.content)], attachment.fileName, {type:blobtype}), blockBlobURL, blobOptions);
            return;
        });
    }
};

【问题讨论】:

  • 那么你得到了什么例外?
  • 无。一切都转移了。这些文件的大小完全相同,一切看起来都一样。当我想打开上传的文件时,它告诉我文件已损坏

标签: javascript azure azure-blob-storage msg


【解决方案1】:

已排序。我认为我只是使用了错误的 blob 格式之类的。

【讨论】:

    猜你喜欢
    • 2018-09-02
    • 2014-07-22
    • 2020-07-05
    • 2014-08-23
    • 2021-11-19
    • 2021-06-20
    • 2017-01-24
    • 2017-08-19
    • 1970-01-01
    相关资源
    最近更新 更多