QCloudCOSXMLUploadObjectRequest Class Reference

Conforms to BodyType
Declared in QCloudCOSXMLUploadObjectRequest.h
QCloudCOSXMLUploadObjectRequest.m

Overview

COSXML上传对象接口。在上传小于1MB的文件时,通过该request来上传的话,会生成一个简单上传putObjectRequset, 将整个对象直接上传。

如果上传的对象大小大于1MB时,我们会在内部进行分片上传的处理,将文件切分成数个1MB大小的块, 然后通过并行分快上传的方式进行上传。

示例

@code

QCloudCOSXMLUploadObjectRequest* put = [QCloudCOSXMLUploadObjectRequest new];
NSURL* url = @"文件的URL";
put.object = @"文件名.jpg";
put.bucket = @"bucket名";
put.body =  url;
[put setSendProcessBlock:^(int64_t bytesSent, int64_t totalBytesSent, int64_t totalBytesExpectedToSend) {
    NSLog(@"upload %lld totalSend %lld aim %lld", bytesSent, totalBytesSent, totalBytesExpectedToSend);
}];
[put setFinishBlock:^(id outputObject, NSError *error) {

}];
[[QCloudCOSTransferMangerService defaultCOSTRANSFERMANGER] UploadObject:put];

  object

上传文件(对象)的文件名,也是对象的key,请注意文件名中不可以含有问号即"?“字符

@property (strong, nonatomic) NSString *object

Declared In

QCloudCOSXMLUploadObjectRequest.h

  bucket

存储桶名称

@property (strong, nonatomic) NSString *bucket

Declared In

QCloudCOSXMLUploadObjectRequest.h

  body

需要上传的对象内容。可以传入NSData或者NSURL类型的变量

@property (strong, nonatomic) BodyType body

Declared In

QCloudCOSXMLUploadObjectRequest.h

  contentType

RFC 2616 中定义用于指示资源的MIME类型,将作为 Object 元数据保存

@property (strong, nonatomic) NSString *contentType

Declared In

QCloudCOSXMLUploadObjectRequest.h

  cacheControl

RFC 2616 中定义的缓存策略,将作为 Object 元数据保存

@property (strong, nonatomic) NSString *cacheControl

Declared In

QCloudCOSXMLUploadObjectRequest.h

  contentDisposition

RFC 2616 中定义的文件名称,将作为 Object 元数据保存

@property (strong, nonatomic) NSString *contentDisposition

Declared In

QCloudCOSXMLUploadObjectRequest.h

  expect

当使用 Expect: 100-continue 时,在收到服务端确认后,才会发送请求内容

@property (strong, nonatomic) NSString *expect

Declared In

QCloudCOSXMLUploadObjectRequest.h

  expires

RFC 2616 中定义的过期时间,将作为 Object 元数据保存

@property (strong, nonatomic) NSString *expires

Declared In

QCloudCOSXMLUploadObjectRequest.h

  storageClass

对象的存储级别

@property (assign, nonatomic) QCloudCOSStorageClass storageClass

Declared In

QCloudCOSXMLUploadObjectRequest.h

  accessControlList

定义 Object 的 ACL(Access Control List) 属性。有效值:private,public-read-write,public-read,默认值:private

@property (strong, nonatomic) NSString *accessControlList

Declared In

QCloudCOSXMLUploadObjectRequest.h

  grantRead

赋予被授权者读的权限。格式:id=“ ”,id=“ "; 当需要给子账户授权时,id="qcs::cam::uin/<OwnerUin>:uin/<SubUin>", 当需要给根账户授权时,id="qcs::cam::uin/<OwnerUin>:uin/<OwnerUin>”

@property (strong, nonatomic) NSString *grantRead

Declared In

QCloudCOSXMLUploadObjectRequest.h

  grantFullControl

赋予被授权者读写权限。格式: id=“ ”,id=“ ” ; 当需要给子账户授权时,id=“qcs::cam::uin/<OwnerUin>:uin/<SubUin>", 当需要给根账户授权时,id="qcs::cam::uin/<OwnerUin>:uin/<OwnerUin>”

@property (strong, nonatomic) NSString *grantFullControl

Declared In

QCloudCOSXMLUploadObjectRequest.h

  aborted

表明该请求是否已经被中断

@property (assign, atomic, readonly) BOOL aborted

Declared In

QCloudCOSXMLUploadObjectRequest.h

  initMultipleUploadFinishBlock

如果该request产生了分片上传的请求,那么在分片上传初始化完成后,会通过这个block来回调, 可以在该回调block中获取分片完成后的bucket, key, uploadID,以及用于后续上传失败后恢复上传的ResumeData。

@property (nonatomic, copy) InitMultipleUploadFinishBlock initMultipleUploadFinishBlock

Declared In

QCloudCOSXMLUploadObjectRequest.h

  enableMD5Verification

是否在上传完成以后,将 COS 返回的文件MD5与本地文件算出来的md5进行校验。默认开启,如果校验出错, 文件仍然会被上传到 COS, 不过我们会在本地抛出校验失败的error。

@property (nonatomic, assign) BOOL enableMD5Verification

Declared In

QCloudCOSXMLUploadObjectRequest.h

– setFinishBlock:

上传完成后会通过该block回调。若error为空,可视为成功。

- (void)setFinishBlock:(void ( ^ _Nullable ) ( QCloudUploadObjectResult *_Nullable result , NSError *_Nullable error ))QCloudRequestFinishBlock

Parameters

QCloudRequestFinishBlock

上传完成后的回调

Declared In

QCloudCOSXMLUploadObjectRequest.h

+ requestWithRequestData:

在初始化分片上传完成以后会回调的block中获取 resumeData,通过 resumeData 生成一个分片上传的请求;

+ (instancetype)requestWithRequestData:(QCloudCOSXMLUploadObjectResumeData _Nullable)resumeData

Declared In

QCloudCOSXMLUploadObjectRequest.h

– cancelByProductingResumeData:

主动调用取消,并且产生 resumetData

- (QCloudCOSXMLUploadObjectResumeData)cancelByProductingResumeData:(NSError *__autoreleasing *)error

Declared In

QCloudCOSXMLUploadObjectRequest.h