【发布时间】:2017-02-16 16:29:48
【问题描述】:
我想使用angularJS提供的$http服务通过XHR下载一个图片文件,并将响应数据(图片数据)上传到OSS(这是阿里巴巴提供的托管文件的服务),它是@ 987654321@是:
表示它将把{String|Buffer|ReadStream}作为第二个参数file,
但是如何传输响应数据,以便我可以将其作为 put(name, file) 方法的参数,例如:
$http.get("http://image.url/file.gif").then(
function success(response){
console.log("type of response.data is :" + typeof response.data);
oss.put("test.jpg", response.data); //<-- here will give an error
},
function fail(response){
console.log("error");
}
)
这会产生类型错误:
【问题讨论】: