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

Convenience method for multipart/form-data requests #258

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

dondi
Copy link

@dondi dondi commented Jun 19, 2018

This is motivated by and based on #190

Hope you don’t mind the warts and all (particularly the missing unit tests) @pcantrell —I’m very much a newbie in iOS dev, but I tried to not let that discourage me and sort of took your invitation from that issue thread at its word 😬

This same code is currently quite functional in an iOS app I’m working on that uploads files to an Amazon S3 bucket by way of a signed S3 URL. A sample call looks like this:

service.resource(absoluteURL: "http://some.multipart-server.com/asset).request(.post,
        multipart: ["key": "12345", "token": "abcde"]
        files: ["file": Resource.FilePart(filename: "image.jpg", type: "image/jpeg", data: data)],
        order: ["token", "key", "file"] // If server requires `token` to come before `key`
    ).onSuccess { entity in
        uploadCallback(entity)
    }.onFailure { error in
        fail(error)
    }

Shoutout and thanks to @Alex293 whose code in the issue thread is still pretty much what this convenience method is.

I’m happy to start the conversation of getting this convenience helper in to Siesta. Thanks!

@pcantrell
Copy link
Member

Thanks for this PR, dondi, and sorry for letting it languish! I love the idea. I’ll give it a design review for the next minor release of Siesta.

@dondi
Copy link
Author

dondi commented Aug 30, 2018

No worries @pcantrell! I know how it goes 🙂 Glad you like the idea and I’ll just monitor the PR as things develop.

@romansavrulin
Copy link

Hello! Any chance to see it merged?

@pcantrell pcantrell added this to To do in 1.6 Apr 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
1.6
  
To do
Development

Successfully merging this pull request may close these issues.

None yet

3 participants