【发布时间】:2018-01-19 09:38:23
【问题描述】:
我正在上传 base64 字符串,但 GraphQL 挂起。如果我将字符串切成少于 50,000 个字符,它就可以工作。在 50,000 个字符之后,graphQL 永远不会进入 resolve 函数,但不会给出错误。在较小的字符串上,它工作得很好。
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 },
},
});
【问题讨论】:
标签: javascript reactjs amazon-s3 graphql aws-appsync