2
Base64文字列をアップロードしていますが、GraphQLがハングアップしています。文字列を50,000文字未満にスライスすると、それは機能します。 50,000文字後、graphQLは決してresolve関数にはなりませんが、エラーは発生しません。小さな文字列では、うまく動作します。GraphQLを使用してAWS S3に画像をアップロードするにはどうすればよいですか?
const file = e.target.files[0];
const reader = new FileReader();
reader.readAsDataURL(file);
reader.onloadend =() => {
const imageArray = reader.result;
this.context.fetch('/graphql', {
body: JSON.stringify({
query: `mutation s3Upload($img: String!) {
s3Upload(file: $img) {
logo,
}
}`,
variables: {
img: imageArray,
},
}),
}).then(response => response.json())
.then(({ data }) => {
console.log(data);
});
}
const s3Upload = {
type: S3Type,
args: {
file: { type: new NonNull(StringType) },
},
resolve: (root, args, { user }) => upload(root, args, user),
};
const S3Type = new ObjectType({
name: 'S3',
fields: {
logo: { type: StringType },
},
});
https://docs.aws.amazon.com/appsync/latest/devguide/building-a-client-app-react.html#complex-objectsはあなたに@Richardをありがとうございます。参照したチュートリアルでは、 'NewPostMutation.js'の変更方法は示されていません。私はこのチュートリアルに従おうとしましたが、これまでにs3 :-(にアップロードするファイルを作ることはできません – SaidAkh