AngularJS 从 $http.put 请求中获取 ETag header

AngularJS get ETag header from $http.put request

使用 S3 MultipartUpload,我需要来自 AngularJS $http.put 请求的 ETag header。但是我似乎无法读取该值。任何帮助表示赞赏。谢谢!

$http({
    method: 'PUT',
    url: url,
    headers: {
        'Content-Type': filetype,
        'Access-Control-Expose-Headers': 'ETag'
    },
    data: part
})
.then(function(response) {
    let test1 = response.headers("ETag");
    let test2 = response.headers();
    console.log(test1, test2); // ---> null {content-length: '0'}
})
.catch(function(error) {
    console.log(error);
});

发现您需要更新 S3 存储桶的颜色:

"ExposeHeaders": [
   "ETag",
   "x-amz-meta-custom-header"
]