I am trying to upload an image from my phone to my cd ..
cd "TrimarkFoodcraft"
bucket:
Amazon S3
How can I get the NSURL of the image the user selected from a func imagePickerController(picker: UIImagePickerController, didFinishPickingImage image: UIImage!, editingInfo: [NSObject : AnyObject]!)
{
var uploadReq = AWSS3TransferManagerUploadRequest()
uploadReq.bucket = "bucketname";
uploadReq.key = "testimage.png"
uploadReq.body = image; //This line needs an NSURL
}
?
答案 0 :(得分:1)
虽然郑洁的回答可能有效。我发现了一种更简单的方法:
let fileURL = NSURL(fileURLWithPath: NSTemporaryDirectory().stringByAppendingPathComponent("imagetoupload"))
let data = UIImagePNGRepresentation(image)
data.writeToURL(fileURL!, atomically: true)
uploadReq.body = fileURL
答案 1 :(得分:0)
First U should save the Image to Document Directory. then Post the URL. U can do like this :
Dim comp As String = sLine.Substring(28, 3)
sw.WriteLine(comp)