[英]Convert Blob to Image file in Javascript
I have tried to convert blobs to image file using the below code.我尝试使用以下代码将 blob 转换为图像文件。
var file = new File([blobs],"Download.png");
This gives me a file with type null这给了我一个类型为 null 的文件
This is my file in console.这是我在控制台中的文件。
lastModified: 1618930293005
lastModifiedDate: Tue Apr 20 2021 07:51:33 GMT-0700 (Pacific Daylight Time) {}
name: "Download.png"
size: 3
type: ""
webkitRelativePath: ""
While I'm trying to download this file, it is downloading as a text file and not an image file.当我试图下载这个文件时,它是作为文本文件而不是图像文件下载的。 Can somebody help me with this?
有人可以帮我吗?
I want to download the original file (ie, Image file)我要下载原始文件(即图像文件)
You can specify the type in the third parameter:您可以在第三个参数中指定类型:
new File([blobs], "Download.png", { type: "image/png" })
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.