Skip to content

Instantly share code, notes, and snippets.

View morengab's full-sized avatar

Gaby Moreno César morengab

  • Austin, Texas
View GitHub Profile
@morengab
morengab / basic-auth.swift
Last active April 7, 2020 08:12 — forked from armstrongnate/basic-auth.swift
HTTP POST Request with Basic Authentication using NSURLSession in Swift
// Other sources: http://swiftdeveloperblog.com/send-http-post-request-example-using-swift-and-php/
// Create request
let baseUrl = "http://www.ocrwebservice.com/restservices/processDocument",
params = "?language=english&gettext=true&outputformat=txt",
requestUrl = NSURL(string: "\(baseUrl)\(params)"),
request = NSMutableURLRequest(URL:requestUrl!)
request.HTTPMethod = "POST";
request.HTTPBodyStream = NSInputStream(fileAtPath: "[/YOUR/FILE/PATH/IMAGE.jpg]")