用的是demo里的代码
// 异步上传
- (
void)uploadObjectAsync {
OSSPutObjectRequest
* put = [OSSPutObjectRequest
new
];
// required fields
put.
bucketName
= @"gogogame-sh"
;
put.
objectKey =
@"lkmtest";
NSString * docDir = [
self
getDocumentDirectory];
put.
uploadingFileURL
= [
NSURL
fileURLWithPath
:[docDir stringByAppendingPathComponent
:
@"file10m"
]];
// optional fields
put.
uploadProgress = ^(
int64_t bytesSent,
int64_t totalByteSent,
int64_t totalBytesExpectedToSend) {
NSLog(
@"%lld, %lld, %lld", bytesSent, totalByteSent, totalBytesExpectedToSend);
};
put.
contentType =
@"";
put.
contentMd5 =
@"";
put.contentEncoding
=
@""
;
put.contentDisposition
=
@""
;
OSSTask * putTask = [
client
putObject:put];
[putTask
continueWithBlock:^
id(
OSSTask *task) {
NSLog(
@"objectKey: %@", put.
objectKey);
if (!task.
error) {
NSLog
(@"upload object success!"
);
}
else {
NSLog
(@"upload object failed, error: %@"
, task.
error
);
}
return
nil;
}];
}
最后报了
2016-04-30 18:24:43.797 oss_ios_demo[2297:1907] upload object failed, error: Error Domain=com.aliyun.oss.clientError Code=8 "The operation couldn’t be completed. (com.aliyun.oss.clientError error 8.)" UserInfo=0x1453e790 {ErrorMessage=Catch exception - *** setObjectForKey: object cannot be nil (key: x-oss-security-token)}
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。