Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I'm using a route to save the images on S3, but when I take a screenshot and paste it, it gives an error #244

Open
NadsonOliveira opened this issue Oct 31, 2023 · 0 comments

Comments

@NadsonOliveira
Copy link

I'm using OnPaste to store my save function in S3, but it's giving 404, could anyone help me solve this problem? here is the code.
`
async function onPastImage(event: React.ClipboardEvent) {
var items = event.clipboardData?.items;

if (items) {
for (var i = 0; i < items.length; i++) {
if (items[i].type.indexOf('image') !== -1) {
//image
let image = items[i].getAsFile();
if (image) {
let imageUpload: File;
imageUpload = new File([image], 'image.png');
console.log('upload', imageUpload);

      const formData = new FormData();

      console.log('const', formData);

      formData.append('image', imageUpload);

      console.log('image', formData);

      await uploadImagesService(formData);
    }
  }
}

}
}
`

<MDEditor value={doc} onPaste={onPastImage} onChange={(event) => { if (event === undefined) { return; } setDoc(event); }} />

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant