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

POST multiple files? #54

Closed
ghost opened this issue Feb 9, 2015 · 1 comment
Closed

POST multiple files? #54

ghost opened this issue Feb 9, 2015 · 1 comment

Comments

@ghost
Copy link

ghost commented Feb 9, 2015

Is it possible/what is the best way to POST multiple files?

@daltoniam
Copy link
Owner

The PUT example shows how to upload a file. Use the provided HTTPUpload object to upload files. All files to upload should be in a HTTPUpload object.

See https://github.com/daltoniam/SwiftHTTP#put for more info.

also a quick example based off that:

let fileUrl = NSURL.fileURLWithPath("/Users/dalton/Desktop/file")!
let fileUrl2 = NSURL.fileURLWithPath("/Users/dalton/Desktop/file2")!
var request = HTTPTask()
request.PUT("http://domain.com/1", parameters:  ["param": "hi", "something": "else", "key": "value","file": HTTPUpload(fileUrl: fileUrl!), "file2": HTTPUpload(fileUrl: fileUrl2!)], success: {(response: HTTPResponse) in
    //do stuff
    },failure: {(error: NSError, response: HTTPResponse?) in
    //error out on stuff
    })

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant