Closed ablbol closed 7 years ago
Hmm. If you do the cropping client side you can export the canvas as a base64 string. You can use the string in a normal GraphQL request variable, and then use it to save an image on the server in the resolver.
To crop or otherwise manipulate images on the server, I suggest using Sharp.
If it makes sense to, we could add Blob
to the list of objects in extract-files
considered files for upload to make uploading from canvas easier via toBlob
. I guess blobs would have to upload with no filename and potentially no mime type.
@ablbol You can use the File constructor to create a File object from a blob object (https://w3c.github.io/FileAPI/#file-constructor)
const file = new File([blob], `image.jpeg`)
@n1ru4l nice.
Closing because the question is answered, but feel free to discuss more 🙂
This is very helpful. Thanks
I have the same problem, trying to upload cropped images. I'm converting a data URI to a blob/file.
@n1ru4l's solution works in Chrome but doesn't appear to work in Webkit.
It seems like passing a Blob to formData.append is required.
Please is this to say that if you crop an image, in my case, react native, upload won't work? Because I am experiencing an issue that I have reported here https://github.com/jaydenseric/apollo-upload-client/issues/64
Please what do you think?
I removed the ability to crop and I am still having the error
How can I resize the image on the server before saving to folder? I'll appreciate complete example too
Hi, Thanks for this great library. I have a question. Is there a way to crop the image before uploading the image or should the image be cropped server side? I noticed that the library deals with File or FileList objects but if I crop the image client side, I am not sure how to change back to File object. Please share any library to crop images server side. Thanks