不懂就问, Blob 类型,怎么通过 fileBinary 属性转化成 ArrayBuffer 的?

yazoox:最近在修一个 legacy bug,看到一段不太懂的代码。

调用的是 dropbox 的 api (参考这个链接)
https://www.dropbox.com/developers/documentation/http/documentation#files-download

这里的 dropbox 的文档就有点问题。该 API 的返回值,其实包含一个 property named fileBlob,类型是 Blob (在文档里面没有写出来)

我们就是通过这个 fileBlob 拿到下载文件的内容。

我们代码大约是:

async get(fileId: string): Promise<ArrayBuffer> {

“blabla...”

const fileData = await [dropbox SDK client API call]
return (fileData as any).fileBinary;

}

成功返回了。内容也都拿到了。但是,这里,我不理解的是,
fileData 的类型是 dropbox.files.FileMetadata, 这个里面只有 property - fileBlob,类型是 Blob,没有 fileBinary 啊?这是怎么通过(fileData as any).fileBinary 转化成 ArrayBuffer 的?

更骚的是,
外面的调用者,直接通过下面这段来判断文件大小,也是成功的。

const fileData = await get("fileid");
(fileData as Buffer).length

google 了一些 ArrayBuffer, Blob, and Buffer 的相关资料,也没发现能够这样转换啊?

特来请教一下。有没有老司机 /大神解惑一下。

谢谢!

不懂就问, Nvidia 收购 ARM 为什么需要中国的批准?

Tony4ee:据 WikiPedia: Arm Ltd. is a British semiconductor and software design company partially owned by American technology company Nvidia and Japanese conglomerate SoftBank Group …

下载C#Excel字节数组并将其转换为JavaScript Blob - javascript

我正在使用POST方法来获取Excel文件的字节数组C#服务器端实现: downloadExcel() { .... FileResultDto fileResultDto = new FileResultDto { Data = ExcelHelper.CreateExcelFile(excelFile) //Data contains the byte …

将音频数据从JS发送到Python - javascript

我正在尝试使用Flask将JS的.wav音频文件(blob)从JS发送到Python。我只是想将文件保存在Python端并能够在我的计算机上播放。这是我的尝试:JS:fetch(serverUrl, { method: "post", body: blob }); 其中blob是Blob {size: 5040, type: "…

firestore数据库添加图像进行记录 - java

我需要将jpeg图像添加到Firestore数据库记录中。我首选的方式是在Sqlite记录中使用的Blob。我在尝试这种方法时遇到了一些问题。以下是到目前为止我最好的尝试:public Blob getImage() { Uri uri = Uri.fromFile(new File(mCurrentPhotoPath)); File f1 = new Fi…

将当前页面保存到图像 - c#

我正在一个需要将当前页面保存在图像中的项目。我在Javascript中找到了一些创建页面斑点的示例,但是我想做的是将页面保存在文件中。我的问题是,是否可以将页面内容保存在图像文件中?是否有插件可以直接做到这一点?如果不是,是否可以保存斑点并在C#中渲染斑点以创建图像? 参考方案 要将页面另存为图像,可以使用http://html2canvas.hertzen…