sean7512 / RestEssentials

Lightweight REST and JSON library for Swift.
MIT License
37 stars 12 forks source link

NSCocoaErrorDomain Code=3840 Error #6

Closed jrlanders closed 7 years ago

jrlanders commented 7 years ago

Hi Sean, The new version remove the put Error I was getting. I am trying to use the Put method to send a file. The interface is for a project called Agiloft. The rest method I am using requires, "Attaches the file passed in the body of the request to the specified field of the record identified by the supplied primary key." I am still trying to figure out how to upload it that what. It is a PDF file and I don't see to understand it yet. The Agiloft indicates that if it were an HTML for it should look like this: \ Characters removed to display ` form method="post" action="https://xxxxxxxx.com/ewws/EWAttach" enctype="multipart/form-data"> input name="$KB" value="Demo" /> input name="$table" value="case" /> input name="$lang" value="en" /> input name="$login" value="admin" /> input name="$password" value="qwerty" /> input type="file" name="inbound_attachments"/>** input type="submit" value="submit" /> /form> `

The error mentioned int he subject line is happening when I try and do a GET. I was not having that issue before the new release. CORRECTION I have resolved the issue mentioned in the subject line but and still working on the file upload issue.

Any Thoughts?

Thanks for all your hard work on this project!

sean7512 commented 7 years ago

@jrlanders Thanks so much for using my library.

At this time, RestEssentials does NOT support multipart file uploads. RestEssentials deals with JSON data types only. If you can change the server, the way you can do it is to have the server accept JSON that looks like:

{
    "fileName": "someFile.png",
    "fileData": "base64EncodedStringOfFile"
}

If you cannot change the server, then there are a few options...

  1. Add the support to RestEssentials and create a pull request to merge it back into the library.
  2. Use AlamoFire. AlamoFire is a much more heavyweight library, but it does support multipart file uploads. If you go this route, can you please create an issue on my library requesting the feature and I may add it in a future release.

Thanks again!

sean7512 commented 7 years ago

@jrlanders I am going to close this issue since you resolved it. If you do not plan on updating the library for file uploads, then please open an issue requesting that feature.

Thanks again.