upload object failed, error: Error Domain=com.aliyun.oss.serverError Code=-400 "(null)" UserInfo={__name=Error, HostId=xzjimg.xzjimg.oss-cn-qingdao.aliyuncs.com, BucketName=xzjimg.xzjimg, Message=The specified bucket is not valid., Code=InvalidBucketName, RequestId=578C994796F2DA846B19520C}
下面的是我上传图片的代码
NSString *endpoint = @"http://oss-cn-qingdao.aliyuncs.com";
NSLog(@"self.testModel.AccessKeySecret:%@",self.testModel.AccessKeySecret);
NSLog(@"self.testModel.AccessKeyId:%@",self.testModel.AccessKeyId);
id<OSSCredentialProvider> credential = [[OSSPlainTextAKSKPairCredentialProvider alloc] initWithPlainTextAccessKey:self.testModel.AccessKeyId secretKey:self.testModel.AccessKeySecret];
OSSClient *client = [[OSSClient alloc] initWithEndpoint:endpoint credentialProvider:credential];
OSSPutObjectRequest *put = [OSSPutObjectRequest new];
put.bucketName = @"xzjimg";
put.objectKey = @"tupian";
UIImage *image = [UIImage imageNamed:@"451512"];
put.uploadingData = UIImageJPEGRepresentation(image, 1);
put.uploadProgress = ^(int64_t bytesSent, int64_t totalByteSent, int64_t totalBytesExpectedToSend) {
// 当前上传段长度、当前已经上传总长度、一共需要上传的总长度
NSLog(@"%lld, %lld, %lld", bytesSent, totalByteSent, totalBytesExpectedToSend);
};
OSSTask *putTask = [client putObject:put];
[putTask continueWithBlock:^id(OSSTask *task) {
if (!task.error) {
NSLog(@"upload object success!");
} else {
NSLog(@"upload object failed, error: %@" , task.error);
}
return nil;
}];
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。