小编Arr*_*ton的帖子

类型错误:无法读取未定义的属性“byteLength” - AWS S3 Upload

我正在从 React 客户端处理 aws s3 照片上传,但遇到以下错误:

TypeError: Cannot read property 'byteLength' of undefined

我假设上传对象存在缺陷,但我相信 s3/cognito 配置可能有问题,因为当我调用s3.listObjects. 我正在关注这些文档 - https://docs.aws.amazon.com/sdk-for-javascript/v2/developer-guide/s3-example-photo-album-full.html

有什么想法吗?

uploadPhoto() {
        const files = document.getElementById("photoUpload").files;
        if (!files.length) {
          return alert("Please choose a file to upload first.");
        }
        const file = files[0];
        const fileName = file.name;
        const albumPhotosKey = encodeURIComponent('screenshots') + "/";
      
        const photoKey = albumPhotosKey + fileName;
        
        // Use S3 ManagedUpload class as it supports multipart uploads
        
        const upload = new AWS.S3.ManagedUpload({
            params: {
              Bucket: <Bucket Name>, …
Run Code Online (Sandbox Code Playgroud)

amazon-s3 amazon-web-services reactjs aws-sdk

15
推荐指数
2
解决办法
2万
查看次数

在本机反应中,如何将视频组件设置为页面背景?

  render() {
    return (

      <View style={styles.container}>


        <Video
          source={{ uri: 'http://d23dyxeqlo5psv.cloudfront.net/big_buck_bunny.mp4' }}
          rate={1.0}
          volume={1.0}
          muted={false}
          resizeMode="cover"
          repeat
          style={{ width: 300, height: 300 }}
        />


      </View>
    );
  }
}
Run Code Online (Sandbox Code Playgroud)

我只是想让视频成为屏幕的背景.我正在使用一个窗口,所以如果没有Xcode,我有点迷失方向.还有另一种方法吗?

video components background ios react-native

6
推荐指数
1
解决办法
8826
查看次数

React Native Android 上的照片上传产生类型错误网络错误

我正在使用 fetch API 执行照片上传,并且不断收到Type Error Network Request Error. 我在模拟器和设备上收到相同的错误。我使用react-native-image-crop-picker作为照片上传数据的来源。有什么想法吗?

const handlePhotoUpload =  async (image: any, token: string) => {

      const { path, filename, mime } = image;

      const uri = path.replace("file://", "")
      const file = {
        uri,            
        type: mime,           
        name: filename             
      };

      const body = new FormData()
      body.append('file', file)

      const config = {
        method: 'POST', 
        headers: { 'Authorization': 'Bearer ' + token },
        body
      };

      return await fetch(`${<API URL>}/user/photo`, config)

}
Run Code Online (Sandbox Code Playgroud)

android multipartform-data fetch react-native

1
推荐指数
1
解决办法
4744
查看次数