【发布时间】:2017-05-25 07:46:32
【问题描述】:
我正在尝试将图像从我的应用上传到我的 heroku 后端,然后将其传递给 Stripe 进行验证。这是我上传和传递图像的快速代码:
@IBAction func registerAccountButtonWasPressed(sender: UIButton) {
let dob = self.dobTextField.text!.components(separatedBy: "/")
let URL = "https://splitterstripeservertest.herokuapp.com/account/create"
var imageData = UIImageJPEGRepresentation(photoID,1)
let params = ["year": UInt(dob[2])! as UInt] as [String : Any]
let manager = AFHTTPSessionManager()
let operation = manager.post(URL, parameters: params, constructingBodyWith: { (formData: AFMultipartFormData!) -> Void in
formData.appendPart(withFileData: imageData!, name: "file", fileName: "photoID.jpg", mimeType: "image/jpeg")
}, success: { (operation, responseObject) -> Void in
print(responseObject!)
}) { (operation, error) -> Void in
self.handleError(error as NSError)
}
}
为了便于阅读,我删除了上面的参数列表并留下了一个。
有没有办法接收这个文件并将其上传到条带,而不必通过传递文件参数来保存它?像这样:
Stripe::FileUpload.create(
{
:purpose => 'identity_document',
:file => params[file]
},
{:stripe_account => params[stripe_account]}
)
还有在条带文档中说要将文件上传到“https://uploads.stripe.com/v1/files”but then shows code to put in your backend,Stripe::FileUpload.create 是否会为我上传到条带?
任何关于这两者的见解都将非常感谢。
【问题讨论】:
标签: swift swift3 stripe-payments