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
S3 Upload from in-memory UIImage #42
Comments
You can save the image to a file (e.g. in the temporary directory), then pass the file path as an |
Well in my case, I don't want to put the image in the file because it is supposed to be unaccessible by the user (the file that we store in the filesystem is encrypted, the UIImage is decrypted in memory). Also our files are not too big, so we don't need to worry about long uploads. I found someone else writing about how to upload NSData in this StackOverflow question, but I am still trying to make it work... let's see where I end up today. |
I though I could make it work like this: AWSS3PutObjectRequest *req = [AWSS3PutObjectRequest new];
req.bucket = bucket;
req.key = imgName;
req.contentType = @"image/png";
req.body = imgData;
req.contentLength = [NSNumber numberWithInteger:[imgData length]];
AWSS3 *transferManager = [[AWSS3 alloc] initWithConfiguration:gAWSServiceConfiguration];
[[transferManager putObject:req] continueWithBlock:^id(BFTask *task) {
if(task.error) {
NSLog(@"ERROR: %@", task.error);
} else {
NSLog(@"SUCCESS: %@", task.result);
}
return nil;
}]; But this code doesn't work. For some reason, it is logging the following error:
Then, knowing that uploading images from memory is not supported on SDKv2 I tried to install SDKv1, but I might give up and have to start thinking on uploading the images to my backend first and then upload from there :( |
Have you read and followed README.md and Set Up the SDK for iOS? It sounds like you are missing the service definition JSON files. |
Yes I did. I guess there is something wrong about this step:
I did put those files on some folder inside my project. How can I know if they are placed in the right place? Maybe "drag and drop" is not enough |
@marioizquierdo you may need to explicitly add them via Xcode's "Add Files to (Project Name" so they are included when built. Im going to try now |
@marioizquierdo |
I have a UIImage that doesn't have a NSUrl path. How could I upload that image to S3 with the SDK?
The text was updated successfully, but these errors were encountered: