Reactjs 如何使用react for AWS s3中的存储从s3渲染我的视频并返回链接
我有一个react应用程序,它会从s3中下拉一个键列表,然后循环遍历它们并获得所需的链接。我需要使用在我的应用程序的渲染部分生成的链接来显示视频Reactjs 如何使用react for AWS s3中的存储从s3渲染我的视频并返回链接,reactjs,amazon-s3,aws-amplify,Reactjs,Amazon S3,Aws Amplify,我有一个react应用程序,它会从s3中下拉一个键列表,然后循环遍历它们并获得所需的链接。我需要使用在我的应用程序的渲染部分生成的链接来显示视频 import Amplify from "aws-amplify"; import { Storage} from 'aws-amplify' import React, {Component} from 'react' import ReactPlayer from 'react-player' import { withAuthenticator}
import Amplify from "aws-amplify";
import { Storage} from 'aws-amplify'
import React, {Component} from 'react'
import ReactPlayer from 'react-player'
import { withAuthenticator} from "aws-amplify-react";
import config from "./aws-exports";
Amplify.configure(config);
const result = ""
class App extends React.Component {
onChange(e) {
const file = e.target.files[0];
const filename = e.target.files[0].name;
console.log("filename", filename)
Storage.put(filename, file, {
contentType: 'video/mp4'
})
.then(result => console.log(result))
.catch(err => console.log(err));
}
render() {
Storage.list('', {
level: 'public'
})
.then((result) => {
Storage.get(result[1].key, {
level: 'public'
})
.then((result) => {
})
.catch((err) => {
console.log(err);
})
})
return (
console.log("result", result), <
ReactPlayer url = {
result
}
playing / >
)
}
}
export default withAuthenticator(App, true);
从“aws放大”导入放大;
从“aws放大”导入{Storage}
从“React”导入React,{Component}
从“react player”导入react player
从“aws放大反应”导入{withAuthenticator};
从“/aws导出”导入配置;
放大。配置(配置);
const result=“”
类应用程序扩展了React.Component{
onChange(e){
const file=e.target.files[0];
const filename=e.target.files[0]。名称;
log(“文件名”,文件名)
Storage.put(文件名、文件名、{
contentType:“视频/mp4”
})
.then(result=>console.log(result))
.catch(err=>console.log(err));
}
render(){
存储列表(“”{
级别:“公共”
})
。然后((结果)=>{
Storage.get(结果[1]。键{
级别:“公共”
})
。然后((结果)=>{
})
.catch((错误)=>{
控制台日志(err);
})
})
返回(
控制台日志(“结果”,结果)<
播放机url={
结果
}
播放/>
)
}
}
使用验证器导出默认值(App,true);
我想要存储结果。为了能够为视频播放渲染,请告诉人们您有什么错误getting@YikSanChan我没有收到任何错误,这就是问题所在:(它只是不知道渲染部分中s3下的结果。您可以添加日志。例如,当您获得
结果
,通过控制台记录它。日志
,这将为您提供更多信息。此外,您不应该在渲染
中进行异步调用。在组件安装
中执行此操作。请阅读plz@YikSanChan谢谢你,这句话让我在正确的方向上,它现在起作用了:请告诉人们你犯了什么错误getting@YikSanChan我没有收到任何错误,这就是问题所在:(它只是不知道渲染部分中s3下的结果。您可以添加日志。例如,当您获得结果
,通过控制台记录它。日志
,这将为您提供更多信息。此外,您不应该在渲染
中进行异步调用。在组件安装
中执行此操作。请阅读plz@YikSanChan谢谢你,这句话让我在正确的方向上,现在它工作了:D