gpt4 book ai didi

ios - AWSS3TransferManagerUploadRequest 获取响应 URL

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:16:06 26 4
gpt4 key购买 nike

我正在使用 v2 AWS iOS SDK 将我的图像上传到服务器我的代码我向前走

 NSString * uniqueIdentifier = [[NSUUID UUID]UUIDString];

AWSS3TransferManagerUploadRequest *uploadRequest = [AWSS3TransferManagerUploadRequest new];
uploadRequest.bucket = @"my bucket";
uploadRequest.key = [NSString stringWithFormat:@"%@/images/%@.jpeg",objectId,uniqueIdentifier];
uploadRequest.ACL = AWSS3ObjectCannedACLPublicRead;

NSData * data = UIImageJPEGRepresentation(newImage, 0.8);

NSString *tmpDirectory = NSTemporaryDirectory();

NSString *tmpFile = [tmpDirectory stringByAppendingPathComponent:[NSString stringWithFormat:@"%@.jpeg",uniqueIdentifier]];
NSLog(@"Temp File:%@", tmpFile);

[data writeToFile:tmpFile atomically:YES];

uploadRequest.body = [NSURL fileURLWithPath:tmpFile];

AWSS3TransferManager *transferManager = [AWSS3TransferManager defaultS3TransferManager];

[[transferManager upload:uploadRequest] continueWithExecutor:[BFExecutor defaultExecutor]
withBlock:^id(BFTask *task) {
if (task.error != nil) {
NSLog(@"%s %@","Error uploading :", uploadRequest.key);
}else {

AWSS3TransferManagerUploadOutput * output = task.result;


NSLog(@"Upload completed %@",[output description]);


}
return nil;
}];

将文件上传到 S3 服务后,响应 URL 在哪里?我怎么知道该图片的网址?我想通过 DB 将图像放入一个对象中。

谢谢

最佳答案

公开可读的 Amazon S3 对象遵循以下 URL 模式:

https://S3Endpoint/BucketName/ObjectName

找出对象 URL 的最简单方法是转到 AWS Management Consolelook在对象的“链接:”处。

关于ios - AWSS3TransferManagerUploadRequest 获取响应 URL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28699709/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com