import React, { PureComponent } from "react";
import FaDownload from "react-icons/lib/fa/download";
import { Auth, API, Storage } from "aws-amplify";
class DownloadCell extends PureComponent {
onclick = async event => {
event.preventDefault();
try {
const stored = await Storage.get(this.props.node.data.Key.split('/')[1])
window.open(stored)
} catch (error) {
console.error("S3 download error: ", error);
}
};
尝试使用AWS Amplify下载s3存储桶文件,不确定如何正确实现它,因此该文件不会在新窗口中显示。
答案 0 :(得分:0)
只需移除window.open()
onclick = async event => {
event.preventDefault();
try {
const stored = await Storage.get(this.props.node.data.Key.split('/')[1])
//whatever you want with the stored
//.....
} catch (error) {
console.error("S3 download error: ", error);
}