如何使用React中的Storage在AWS s3中使用链接返回从s3渲染我的视频

时间:2019-06-14 01:36:19

标签: 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} 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);

我希望Storage.get的结果能够在视频播放中呈现

0 个答案:

没有答案