-
Notifications
You must be signed in to change notification settings - Fork 731
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
File Upload Issue #1015
Comments
The |
Thank you for the super fast reply! Ah you're right. My bad.
I then adjusted the image size by using: guard let data = image.jpegData(compressionQuality: 0.1) else { //Should bring that image down to a size of 807681*.01 = 80,768.1
delegate.onAttachmentFailure(error: "Unable to attach image")
print("Unable to convert image to JPEG")
return
} And now I'm right back to throwing the same error:
|
Hm, I bet it was just blindly looking at the size of the object and going NOPE rather than trying to evaluate anything, so it's probably still the same problem. What happens if you try If that doesn't work, do you have the ability through Charles or another proxy to send the multipart-form data (not the bit of it that's the file itself, just the headers of that part)? |
I tried setting the fieldName to: "file", "files", "field", and "fields". It throws the same error with them all. Thanks again for all your hard work on this. |
I think you might be able to log out the contents of the request before it hits the network if you implement the |
|
Frak. I meant And there aren't any error checks in the And if you can convert the |
I'm not having any luck converting the body data to a string. Breakpoint and
print("(request.httpBody)") yields:
print(NSString(data: request.httpBody!, encoding: String.Encoding.utf8.rawValue)) yields:
|
Try |
No luck. Just prints |
Is that in |
That's in |
🤔yeah let me fight with that a bit with the tests. |
|
Looks like there is a file in the fileUpload, but somewhere there's a null value causing it to fail. |
Yeah the print appears to be failing because you're force-unwrapping a null body. Can you print out |
I still think the Can you please send me a sample project so I can dig into this deeper? ellen at apollographql dot com. |
Hi, sorry. I've been out for a little while. I have been trying each time once with "file" and once with "files". What would you need for the sample project? |
|
One thing I will note for this and all other uploading issues: One strategy we've seen have folks have better long-term success with over GQL-based uploads is uploading the file to another service (such as S3 or even your own backend) and then only sending the URL of the file via GraphQL. This is an article about the web, but it's got useful examples. |
Hi @designatednerd. I also ended up using a multipartFormData file upload using AlamoFire straight to our server, then just patching the GQL object using the fileID. As far as the sample project, I can't share most of that info. I would be happy to try any possible solutions you come across in the future though. |
Yeah that's a totally reasonable (and tbh, recommended) workaround. Do you want to keep this issue open or close it out? |
@m-skolnick How did you get Upload object in |
@designatednerd I would say keep it open as it's still an issue. Completely up to you though. @jessjpj I ended up uploading the file outside of GraphQL, then patching the fileID using GraphQL. I did not put the upload object in |
@jessjpj You'll probably need to make sure you're using the I'm gonna close this issue out - we're now actively recommending people use a more purpose-built uploader in the docs, and I've already got on my roadmap to try to deal with uploads a bit better in new codegen, so I think the existence of problems here is pretty well-covered. Thanks a lot for getting back to me @m-skolnick, and sorry I couldn't be of more help! |
where is passthroughCustomScalars set exactly? in the codegen folder? where abouts? |
If you're using the Swift Scripting method, it's on |
i get the error of extra argument in call let codegenOptions = ApolloCodegenOptions(targetRootURL: targetRootURL, customScalarFormat: .passthrough) Is there an example of the otherway? other than: let codegenOptions = ApolloCodegenOptions(targetRootURL: targetRootURL) |
Use the initializer with a whole mess of parameters on it - the one that just starts with target root URL is a convenience initializer and is not meant for use with this. |
I was able to get a BigInt custom scalar working using
But the custom scalar 'Upload' now errors with "//API.swift:3891:14: Property cannot be declared public because its type uses an internal type" and "Cannot find type 'Upload' in scope" and I have set "typealias Upload = String", so Im not sure what Im missing here I use the following for the BigInt custom scalar:
Do I need to create something for the Upload scalar now? EDIT: Turns out I just needed to add public in front of the type alias public typealias Upload = String |
Hello. I'm also having a file upload issue. It may be related to #1013 I tried the docs, and this reply: kimdv commented on Aug 7, 2019 all to no avail. At this point I'm not really sure what else to try. Any help would be appreciated. Thanks in advance.
Mutation (The generated class is at the bottom because of length)
UploadFile
Error Response
error.localizedDescription
error
Generated Mutation
The text was updated successfully, but these errors were encountered: