我正在从 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) 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,我有点迷失方向.还有另一种方法吗?
我正在使用 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) react-native ×2
amazon-s3 ×1
android ×1
aws-sdk ×1
background ×1
components ×1
fetch ×1
ios ×1
reactjs ×1
video ×1