-
Notifications
You must be signed in to change notification settings - Fork 741
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
Image Uploading with apollo #938
Comments
Hey @DeekshaApptunix - where are you receiving that error, in Swift or in an error returned from the server? If it's the latter, it sounds like something's not working properly on the server. |
Another thing to look out for is that |
(also you need to use the |
I need to upload in this mutation if let logoData = btnCommunity.currentImage?.jpegData(compressionQuality: 0.8) , let coverData = coverImage.image?.jpegData(compressionQuality: 0.8) { let uploadData = CreateCommunityMutation(communityDetail:communityDetail, invitedusers: invitedUser, file: "(file)", communityLogo: "(logo)") Here is my mutation for the same mutation createCommunity($communityDetail:CommunityInput!,$invitedusers:[ID],$file:Upload,$communityLogo:Upload){ I am getting following error createReadStream is not a function |
Hi Deesha, Where is the I would also caution that I don't think our current handling of multipart form uploads will allow more than a single file per operation to be uploaded, you'll likely need to break things out a bit. |
@designatednerd createReadStream is not a function is coming from backend. I need to send two different images in single mutation with different parameters. createCommunity(community:CommunityInput! , users:[ID], file: Upload , logo: Upload ){ I am sending it like this: if let logoData = btnCommunity.currentImage?.jpegData(compressionQuality: 0.8) , let coverData = coverImage.image?.jpegData(compressionQuality: 0.8) { let uploadData = CreateCommunityMutation(communityDetail:communityDetail, invitedusers: invitedUser, file: "(file)", communityLogo: "(logo)") Now please let me know what I need to send in files array ? |
You need to send the created Based on what you're doing above, it looks like what you need to do is: apollo.upload(operation:uploadData, files:[coverFile, logoFile]) { result in |
If I am sending data like you suggested then I am getting following error Error while create user: Received error response (400 bad request): <title>Error</title>BadRequestError: Invalid object path for the ‘map’ multipart field entry key ‘0’ array index ‘0’ value ‘variables.file.0’ (https://github.com/jaydenseric/graphql-multipart-request-spec). |
@designatednerd also let me know how to upload multiple images with graphql in swift 4 |
Uploading is not supported in versions of the library which support Swift 4 - Uploading was added in v0.13.0, and Swift 5 has been the supported version since 0.11.0. |
Looks like your server is using this upload plugin - can you confirm that's the case, and if so, what version it's using? The current version is 9.0.0, and supports v2.0 of the GraphQL upload spec, which is what we support. |
@DeekshaApptunix Were you able to find out what version of the upload plugin your server team is using? |
I'm going to close this out, but @DeekshaApptunix please feel free to reopen if you get further information. Anyone else with a similar problem, please open a new issue. Thank you! |
@designatednerd Upload functionality is perfectly working for a single image. For multiple images, it's returning 400 error. Can you help me with this? |
@MeriGarala Please see #1279 for what should be a solution to that. |
I need to upload user image at signup time, Here is my code
let name = UUID().uuidString
if let imageData = userImgVew.image?.jpegData(compressionQuality: 0.7) {
let file = GraphQLFile(fieldName: "(name).png", originalName: "(name)", mimeType: "image/jpeg", data:imageData)
apollo.perform(mutation:UpdateUserProfileMutation.init(userId:id, userImage:file, userDetail: userDict))
I am getting following error :
Cannot convert value of type 'GraphQLFile' to expected argument type 'String?'
I also tried it with upload method
let name = UUID().uuidString
if let imageData = userImgVew.image?.jpegData(compressionQuality: 0.7) {
let file = GraphQLFile(fieldName: "(name).png", originalName: "(name)", mimeType: "image/jpeg", data:imageData)
let uploadData = UpdateUserProfileMutation(userId:id, userImage:file.fieldName, userDetail: userDict)
apollo.upload(operation:uploadData,files:[file]){ result in
I am getting following error :
createReadStream is not a function
The text was updated successfully, but these errors were encountered: