OSSModel.h 36 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508
  1. //
  2. // OSSModel.h
  3. // oss_ios_sdk
  4. //
  5. // Created by zhouzhuo on 8/16/15.
  6. // Copyright (c) 2015 aliyun.com. All rights reserved.
  7. //
  8. #import <Foundation/Foundation.h>
  9. #import "OSSRequest.h"
  10. #import "OSSResult.h"
  11. @class OSSAllRequestNeededMessage;
  12. @class OSSFederationToken;
  13. @class OSSTask;
  14. @class OSSClientConfiguration;
  15. NS_ASSUME_NONNULL_BEGIN
  16. typedef OSSFederationToken * _Nullable (^OSSGetFederationTokenBlock) (void);
  17. /**
  18. Categories NSDictionary
  19. */
  20. @interface NSDictionary (OSS)
  21. - (NSString *)base64JsonString;
  22. @end
  23. /**
  24. A thread-safe dictionary
  25. */
  26. @interface OSSSyncMutableDictionary : NSObject
  27. @property (nonatomic, strong) NSMutableDictionary *dictionary;
  28. @property (nonatomic, strong) dispatch_queue_t dispatchQueue;
  29. - (id)objectForKey:(id)aKey;
  30. - (NSArray *)allKeys;
  31. - (void)setObject:(id)anObject forKey:(id <NSCopying>)aKey;
  32. - (void)removeObjectForKey:(id)aKey;
  33. @end
  34. /**
  35. FederationToken class
  36. */
  37. @interface OSSFederationToken : NSObject
  38. @property (nonatomic, copy) NSString * tAccessKey;
  39. @property (nonatomic, copy) NSString * tSecretKey;
  40. @property (nonatomic, copy) NSString * tToken;
  41. /**
  42. Token's expiration time in milliseconds of the unix time.
  43. */
  44. @property (atomic, assign) int64_t expirationTimeInMilliSecond;
  45. /**
  46. Token's expiration time in GMT format string.
  47. */
  48. @property (atomic, strong, nullable) NSString *expirationTimeInGMTFormat;
  49. @end
  50. /**
  51. CredentialProvider protocol, needs to implement sign API.
  52. */
  53. @protocol OSSCredentialProvider <NSObject>
  54. @optional
  55. - (nullable NSString *)sign:(NSString *)content error:(NSError **)error;
  56. @end
  57. /**
  58. The plaint text AK/SK credential provider for test purposely.
  59. */
  60. __attribute__((deprecated("PLEASE DO NOT USE THIS CLASS AGAIN")))
  61. @interface OSSPlainTextAKSKPairCredentialProvider : NSObject <OSSCredentialProvider>
  62. @property (nonatomic, copy) NSString * accessKey;
  63. @property (nonatomic, copy) NSString * secretKey;
  64. - (instancetype)initWithPlainTextAccessKey:(NSString *)accessKey
  65. secretKey:(NSString *)secretKey __attribute__((deprecated("We recommend the STS authentication mode on mobile")));
  66. @end
  67. /**
  68. TODOTODO
  69. The custom signed credential provider
  70. */
  71. @interface OSSCustomSignerCredentialProvider : NSObject <OSSCredentialProvider>
  72. @property (nonatomic, copy, readonly,) NSString * _Nonnull (^ _Nonnull signContent)( NSString * _Nonnull , NSError * _Nullable *_Nullable);
  73. + (instancetype _Nullable)new NS_UNAVAILABLE;
  74. - (instancetype _Nullable)init NS_UNAVAILABLE;
  75. /**
  76. * During the task execution, this API is called for signing
  77. * It's executed at the background thread instead of UI thread.
  78. */
  79. - (instancetype _Nullable)initWithImplementedSigner:(OSSCustomSignContentBlock)signContent NS_DESIGNATED_INITIALIZER;
  80. @end
  81. /**
  82. TODOTODO
  83. User's custom federation credential provider.
  84. */
  85. @interface OSSFederationCredentialProvider : NSObject <OSSCredentialProvider>
  86. @property (nonatomic, strong) OSSFederationToken * cachedToken;
  87. @property (nonatomic, copy) OSSFederationToken * (^federationTokenGetter)(void);
  88. /**
  89. During the task execution, this method is called to get the new STS token.
  90. It runs in the background thread, not the UI thread.
  91. */
  92. - (instancetype)initWithFederationTokenGetter:(OSSGetFederationTokenBlock)federationTokenGetter;
  93. - (nullable OSSFederationToken *)getToken:(NSError **)error;
  94. @end
  95. /**
  96. The STS token's credential provider.
  97. */
  98. __attribute__((deprecated("Please use OSSAuthCredentialProvider or its subClass instead!")))
  99. @interface OSSStsTokenCredentialProvider : NSObject <OSSCredentialProvider>
  100. @property (nonatomic, copy) NSString * accessKeyId;
  101. @property (nonatomic, copy) NSString * secretKeyId;
  102. @property (nonatomic, copy) NSString * securityToken;
  103. - (OSSFederationToken *)getToken;
  104. - (instancetype)initWithAccessKeyId:(NSString *)accessKeyId
  105. secretKeyId:(NSString *)secretKeyId
  106. securityToken:(NSString *)securityToken;
  107. @end
  108. /**
  109. Auth credential provider require a STS INFO Server URL,also you can customize a decoder block which returns json data.
  110. OSSAuthCredentialProvider *acp = [[OSSAuthCredentialProvider alloc] initWithAuthServerUrl:@"sts_server_url" responseDecoder:^NSData * (NSData * data) {
  111. // 1.hanle response from server.
  112. // 2.initialize json object from step 1. json object require message like {AccessKeyId:@"xxx",AccessKeySecret:@"xxx",SecurityToken:@"xxx",Expiration:@"xxx"}
  113. // 3.generate jsonData from step 2 and return it.
  114. }];
  115. */
  116. @interface OSSAuthCredentialProvider : OSSFederationCredentialProvider
  117. @property (nonatomic, copy) NSString * authServerUrl;
  118. @property (nonatomic, copy) NSData * (^responseDecoder)(NSData *);
  119. - (instancetype)initWithAuthServerUrl:(NSString *)authServerUrl;
  120. - (instancetype)initWithAuthServerUrl:(NSString *)authServerUrl responseDecoder:(nullable OSSResponseDecoderBlock)decoder;
  121. @end
  122. /**
  123. OSSClient side configuration.
  124. */
  125. @interface OSSClientConfiguration : NSObject
  126. /**
  127. Max retry count
  128. */
  129. @property (nonatomic, assign) uint32_t maxRetryCount;
  130. /**
  131. Max concurrent requests
  132. */
  133. @property (nonatomic, assign) uint32_t maxConcurrentRequestCount;
  134. /**
  135. Flag of enabling background file transmit service.
  136. Note: it's only applicable for file upload.
  137. */
  138. @property (nonatomic, assign) BOOL enableBackgroundTransmitService;
  139. /**
  140. Flag of using Http request for DNS resolution.
  141. */
  142. @property (nonatomic, assign) BOOL isHttpdnsEnable;
  143. /**
  144. Sets the session Id for background file transmission
  145. */
  146. @property (nonatomic, copy) NSString * backgroundSesseionIdentifier;
  147. /**
  148. Sets request timeout
  149. */
  150. @property (nonatomic, assign) NSTimeInterval timeoutIntervalForRequest;
  151. /**
  152. Sets single object download's max time
  153. */
  154. @property (nonatomic, assign) NSTimeInterval timeoutIntervalForResource;
  155. /**
  156. Sets proxy host and port.
  157. */
  158. @property (nonatomic, copy) NSString * proxyHost;
  159. @property (nonatomic, strong) NSNumber * proxyPort;
  160. /**
  161. Sets UA
  162. */
  163. @property (nonatomic, copy) NSString * userAgentMark;
  164. /**
  165. Sets the flag of using Second Level Domain style to access the endpoint. By default it's false.
  166. */
  167. @property (nonatomic, assign) BOOL isPathStyleAccessEnable;
  168. /**
  169. Sets the flag of using custom path prefix to access the endpoint. By default it's false.
  170. */
  171. @property (nonatomic, assign) BOOL isCustomPathPrefixEnable;
  172. /**
  173. Sets CName excluded list.
  174. */
  175. @property (nonatomic, strong, setter=setCnameExcludeList:) NSArray * cnameExcludeList;
  176. /**
  177. 是否开启crc校验(当同时设置了此选项和请求中的checkCRC开关时,以请求中的checkCRC开关为准)
  178. */
  179. @property (nonatomic, assign) BOOL crc64Verifiable;
  180. @end
  181. @protocol OSSRequestInterceptor <NSObject>
  182. - (OSSTask *)interceptRequestMessage:(OSSAllRequestNeededMessage *)request;
  183. @end
  184. /**
  185. Signs the request when it's being created.
  186. */
  187. @interface OSSSignerInterceptor : NSObject <OSSRequestInterceptor>
  188. @property (nonatomic, strong) id<OSSCredentialProvider> credentialProvider;
  189. - (instancetype)initWithCredentialProvider:(id<OSSCredentialProvider>)credentialProvider;
  190. @end
  191. /**
  192. Updates the UA when creating the request.
  193. */
  194. @interface OSSUASettingInterceptor : NSObject <OSSRequestInterceptor>
  195. @property (nonatomic, weak) OSSClientConfiguration *clientConfiguration;
  196. - (instancetype)initWithClientConfiguration:(OSSClientConfiguration *) clientConfiguration;
  197. @end
  198. /**
  199. Fixes the time skew issue when creating the request.
  200. */
  201. @interface OSSTimeSkewedFixingInterceptor : NSObject <OSSRequestInterceptor>
  202. @end
  203. /**
  204. The download range of OSS object
  205. */
  206. @interface OSSRange : NSObject
  207. @property (nonatomic, assign) int64_t startPosition;
  208. @property (nonatomic, assign) int64_t endPosition;
  209. - (instancetype)initWithStart:(int64_t)start
  210. withEnd:(int64_t)end;
  211. /**
  212. * Converts the header to string: 'bytes=${start}-${end}'
  213. */
  214. - (NSString *)toHeaderString;
  215. @end
  216. #pragma mark RequestAndResultClass
  217. /**
  218. The request to list all buckets of current user.
  219. */
  220. @interface OSSGetServiceRequest : OSSRequest
  221. /**
  222. The prefix filter for listing buckets---optional.
  223. */
  224. @property (nonatomic, copy) NSString * prefix;
  225. /**
  226. The marker filter for listing buckets----optional.
  227. The marker filter is to ensure any returned bucket name must be greater than the marker in the lexicographic order.
  228. */
  229. @property (nonatomic, copy) NSString * marker;
  230. /**
  231. The max entries to return. By default it's 100 and max value of this property is 1000.
  232. */
  233. @property (nonatomic, assign) int32_t maxKeys;
  234. @end
  235. /**
  236. The result class of listing all buckets
  237. */
  238. @interface OSSGetServiceResult : OSSResult
  239. /**
  240. The owner Id
  241. */
  242. @property (nonatomic, copy) NSString * ownerId;
  243. /**
  244. Bucket owner name---currently it's same as owner Id.
  245. */
  246. @property (nonatomic, copy) NSString * ownerDispName;
  247. /**
  248. The prefix of this query. It's only set when there's remaining buckets to return.
  249. */
  250. @property (nonatomic, copy) NSString * prefix;
  251. /**
  252. The marker of this query. It's only set when there's remaining buckets to return.
  253. */
  254. @property (nonatomic, copy) NSString * marker;
  255. /**
  256. The max buckets to return. It's only set when there's remaining buckets to return.
  257. */
  258. @property (nonatomic, assign) int32_t maxKeys;
  259. /**
  260. Flag of the result is truncated. If it's truncated, it means there's remaining buckets to return.
  261. */
  262. @property (nonatomic, assign) BOOL isTruncated;
  263. /**
  264. The marker for the next ListBucket call. It's only set when there's remaining buckets to return.
  265. */
  266. @property (nonatomic, copy) NSString * nextMarker;
  267. /**
  268. The container of the buckets. It's a dictionary array, in which every element has keys "Name", "CreationDate" and "Location".
  269. */
  270. @property (nonatomic, strong, nullable) NSArray * buckets;
  271. @end
  272. /**
  273. The request to create bucket
  274. */
  275. @interface OSSCreateBucketRequest : OSSRequest
  276. /**
  277. * 存储空间,命名规范如下:(1)只能包括小写字母、数字和短横线(-);(2)必须以小写字母或者数字开头和结尾;(3)长度必须在3-63字节之间.
  278. */
  279. @property (nonatomic, copy) NSString * bucketName;
  280. /**
  281. The bucket location
  282. For more information about OSS datacenter and endpoint, please check out <a>https://docs.aliyun.com/#/pub/oss/product-documentation/domain-region</a>
  283. */
  284. @property (nonatomic, copy) NSString * location __attribute__ ((deprecated));
  285. /**
  286. Sets Bucket access permission. For now there're three permissions:public-read-write,public-read and private. if this key is not set, the default value is private
  287. */
  288. @property (nonatomic, copy) NSString * xOssACL;
  289. @property (nonatomic, assign) OSSBucketStorageClass storageClass;
  290. - (NSString *)storageClassAsString;
  291. @end
  292. /**
  293. Result class of bucket creation
  294. */
  295. @interface OSSCreateBucketResult : OSSResult
  296. /**
  297. Bucket datacenter
  298. */
  299. @property (nonatomic, copy) NSString * location;
  300. @end
  301. /**
  302. The request class of deleting bucket
  303. */
  304. @interface OSSDeleteBucketRequest : OSSRequest
  305. /**
  306. Bucket name
  307. */
  308. @property (nonatomic, copy) NSString * bucketName;
  309. @end
  310. /**
  311. Result class of deleting bucket
  312. */
  313. @interface OSSDeleteBucketResult : OSSResult
  314. @end
  315. /**
  316. The request class of listing objects under a bucket
  317. */
  318. @interface OSSGetBucketRequest : OSSRequest
  319. /**
  320. Bucket name
  321. */
  322. @property (nonatomic, copy) NSString * bucketName;
  323. /**
  324. The delimiter is very important and it determines the behavior of common prefix.
  325. For most cases, use the default '/' as the delimiter.
  326. For example, if a bucket has folder 'prefix/' and a file 'abc'. And inside the folder it has file '123.txt'
  327. If the delimiter is '/', then the ListObject will return a common prefix 'prefix/' and a file 'abc'.
  328. If the delimiter is something else, then ListObject will return three files: prefix/, abc and prefix/123.txt. No common prefix!.
  329. */
  330. @property (nonatomic, copy) NSString * delimiter;
  331. /**
  332. The marker filter for listing objects----optional.
  333. The marker filter is to ensure any returned object name must be greater than the marker in the lexicographic order.
  334. */
  335. @property (nonatomic, copy) NSString * marker;
  336. /**
  337. The max entries count to return. By default it's 100 and it could be up to 1000.
  338. */
  339. @property (nonatomic, assign) int32_t maxKeys;
  340. /**
  341. The filter prefix of the objects to return----the returned objects' name must have the prefix.
  342. */
  343. @property (nonatomic, copy) NSString * prefix;
  344. @end
  345. /**
  346. The result class of listing objects.
  347. */
  348. @interface OSSGetBucketResult : OSSResult
  349. /**
  350. Bucket name
  351. */
  352. @property (nonatomic, copy) NSString * bucketName;
  353. /**
  354. The prefix of the objects returned----the returned objects must have this prefix.
  355. */
  356. @property (nonatomic, copy) NSString * prefix;
  357. /**
  358. The marker filter of the objects returned---all objects returned are greater than this marker in lexicographic order.
  359. */
  360. @property (nonatomic, copy) NSString * marker;
  361. /**
  362. The max entries to return. By default it's 100 and it could be up to 1000.
  363. */
  364. @property (nonatomic, assign) int32_t maxKeys;
  365. /**
  366. The delimiter to differentiate the folder object and file object.
  367. For object whose name ends with the delimiter, then it's treated as folder or common prefixes.
  368. */
  369. @property (nonatomic, copy) NSString * delimiter;
  370. /**
  371. The maker for the next call. If no more entries to return, it's null.
  372. */
  373. @property (nonatomic, copy) NSString * nextMarker;
  374. /**
  375. Flag of truncated result. If it's truncated, it means there's more entries to return.
  376. */
  377. @property (nonatomic, assign) BOOL isTruncated;
  378. /**
  379. The dictionary arrary, in which each dictionary has keys of "Key", "LastModified", "ETag", "Type", "Size", "StorageClass" and "Owner".
  380. */
  381. @property (nonatomic, strong, nullable) NSArray * contents;
  382. /**
  383. The arrary of common prefixes. Each element is one common prefix.
  384. */
  385. @property (nonatomic, strong) NSArray * commentPrefixes;
  386. @end
  387. /**
  388. The request class to get the bucket ACL.
  389. */
  390. @interface OSSGetBucketACLRequest : OSSRequest
  391. /**
  392. Bucket name
  393. */
  394. @property (nonatomic, copy) NSString * bucketName;
  395. @end
  396. /**
  397. The result class to get the bucket ACL.
  398. */
  399. @interface OSSGetBucketACLResult : OSSResult
  400. /**
  401. The bucket ACL. It could be one of the three values: private/public-read/public-read-write.
  402. */
  403. @property (nonatomic, copy) NSString * aclGranted;
  404. @end
  405. /**
  406. The request class to get object metadata
  407. */
  408. @interface OSSHeadObjectRequest : OSSRequest
  409. /**
  410. Bucket name
  411. */
  412. @property (nonatomic, copy) NSString * bucketName;
  413. /**
  414. Object name
  415. */
  416. @property (nonatomic, copy) NSString * objectKey;
  417. @end
  418. /**
  419. The result class of getting object metadata.
  420. */
  421. @interface OSSHeadObjectResult : OSSResult
  422. /**
  423. Object metadata
  424. */
  425. @property (nonatomic, copy) NSDictionary * objectMeta;
  426. @end
  427. /**
  428. The request class to get object
  429. */
  430. @interface OSSGetObjectRequest : OSSRequest
  431. /**
  432. Bucket name
  433. */
  434. @property (nonatomic, copy) NSString * bucketName;
  435. /**
  436. Object name
  437. */
  438. @property (nonatomic, copy) NSString * objectKey;
  439. /**
  440. OSS Download Range: For example, bytes=0-9 means uploading the first to the tenth's character.
  441. */
  442. @property (nonatomic, strong) OSSRange * range;
  443. /**
  444. The local file path to download to.
  445. */
  446. @property (nonatomic, strong) NSURL * downloadToFileURL;
  447. /**
  448. Image processing configuration.
  449. */
  450. @property (nonatomic, copy) NSString * xOssProcess;
  451. /**
  452. Download progress callback.
  453. It runs at background thread.
  454. */
  455. @property (nonatomic, copy) OSSNetworkingDownloadProgressBlock downloadProgress;
  456. /**
  457. During the object download, the callback is called upon response is received.
  458. It runs under background thread (not UI thread)
  459. */
  460. @property (nonatomic, copy) OSSNetworkingOnRecieveDataBlock onRecieveData;
  461. /**
  462. * set request headers
  463. */
  464. @property (nonatomic, copy) NSDictionary *headerFields;
  465. @end
  466. /**
  467. Result class of downloading an object.
  468. */
  469. @interface OSSGetObjectResult : OSSResult
  470. /**
  471. The in-memory content of the downloaded object, if the local file path is not specified.
  472. */
  473. @property (nonatomic, strong) NSData * downloadedData;
  474. /**
  475. The object metadata dictionary
  476. */
  477. @property (nonatomic, copy) NSDictionary * objectMeta;
  478. @end
  479. /**
  480. The response class to update the object ACL.
  481. */
  482. @interface OSSPutObjectACLResult : OSSResult
  483. @end
  484. /**
  485. The request class to upload an object.
  486. */
  487. @interface OSSPutObjectRequest : OSSRequest
  488. /**
  489. Bucket name
  490. */
  491. @property (nonatomic, copy) NSString * bucketName;
  492. /**
  493. Object name
  494. */
  495. @property (nonatomic, copy) NSString * objectKey;
  496. /**
  497. The in-memory data to upload.
  498. */
  499. @property (nonatomic, strong) NSData * uploadingData;
  500. /**
  501. The local file path to upload.
  502. */
  503. @property (nonatomic, strong) NSURL * uploadingFileURL;
  504. /**
  505. The callback parameters.
  506. */
  507. @property (nonatomic, copy) NSDictionary * callbackParam;
  508. /**
  509. The callback variables.
  510. */
  511. @property (nonatomic, copy) NSDictionary * callbackVar;
  512. /**
  513. The content type.
  514. */
  515. @property (nonatomic, copy) NSString * contentType;
  516. /**
  517. The content's MD5 digest.
  518. It's calculated on the request body (not headers) according to RFC 1864 to get the 128 bit digest data.
  519. Then use base64 encoding on the 128bit result to get this MD5 value.
  520. This header is for integrity check on the data. And it's recommended to turn on for every body.
  521. */
  522. @property (nonatomic, copy) NSString * contentMd5;
  523. /**
  524. Specifies the download name of the object. Checks out RFC2616 for more details.
  525. */
  526. @property (nonatomic, copy) NSString * contentDisposition;
  527. /**
  528. Specifies the content encoding during the download. Checks out RFC2616 for more details.
  529. */
  530. @property (nonatomic, copy) NSString * contentEncoding;
  531. /**
  532. Specifies the cache behavior during the download. Checks out RFC2616 for more details.
  533. */
  534. @property (nonatomic, copy) NSString * cacheControl;
  535. /**
  536. Expiration time in milliseconds. Checks out RFC2616 for more details.
  537. */
  538. @property (nonatomic, copy) NSString * expires;
  539. /**
  540. The object's metadata.
  541. When the object is being uploaded, it could be specified with http headers prefixed with x-oss-meta for user metadata.
  542. The total size of all user metadata cannot be more than 8K.
  543. It also could include standard HTTP headers in this object.
  544. */
  545. @property (nonatomic, copy) NSDictionary * objectMeta;
  546. /**
  547. The upload progress callback.
  548. It runs in background thread (not UI thread).
  549. */
  550. @property (nonatomic, copy) OSSNetworkingUploadProgressBlock uploadProgress;
  551. /**
  552. The upload retry callback.
  553. It runs in background thread (not UI thread).
  554. */
  555. @property (nonatomic, copy) OSSNetworkingRetryBlock uploadRetryCallback;
  556. /**
  557. * the sha1 of content
  558. */
  559. @property (nonatomic, copy) NSString *contentSHA1;
  560. @end
  561. /**
  562. The request class to update the object ACL.
  563. */
  564. @interface OSSPutObjectACLRequest : OSSPutObjectRequest
  565. /**
  566. *@brief:指定oss创建object时的访问权限,合法值:public-read、private、public-read-write
  567. */
  568. @property (nonatomic, copy, nullable) NSString *acl;
  569. @end
  570. /**
  571. The result class to put an object
  572. */
  573. @interface OSSPutObjectResult : OSSResult
  574. /**
  575. ETag (entity tag) is the tag during the object creation in OSS server side.
  576. It's the MD5 value for put object request. If the object is created by other APIs, the ETag is the UUID of the content.
  577. ETag could be used to check if the object has been updated.
  578. */
  579. @property (nonatomic, copy) NSString * eTag;
  580. /**
  581. If the callback is specified, this is the callback response result.
  582. */
  583. @property (nonatomic, copy) NSString * serverReturnJsonString;
  584. @end
  585. /**
  586. * append object request
  587. */
  588. @interface OSSAppendObjectRequest : OSSRequest
  589. /**
  590. Bucket name
  591. */
  592. @property (nonatomic, copy) NSString * bucketName;
  593. /**
  594. Object name
  595. */
  596. @property (nonatomic, copy) NSString * objectKey;
  597. /**
  598. Specifies which position to append. For a new file, the first append should start from 0. And the subsequential calls will start from the current length of the object.
  599. For example, if the first append's size is 65536, then the appendPosition value in the next call will be 65536.
  600. In its response, the header x-oss-next-append-position is included for next call.
  601. */
  602. @property (nonatomic, assign) int64_t appendPosition;
  603. /**
  604. The in-memory data to upload from.
  605. */
  606. @property (nonatomic, strong) NSData * uploadingData;
  607. /**
  608. The local file path to upload from.
  609. */
  610. @property (nonatomic, strong) NSURL * uploadingFileURL;
  611. /**
  612. Sets the content type
  613. */
  614. @property (nonatomic, copy) NSString * contentType;
  615. /**
  616. The content's MD5 digest value.
  617. It's calculated from the MD5 value of the request body according to RFC 1864 and then encoded by base64.
  618. */
  619. @property (nonatomic, copy) NSString *contentMd5;
  620. /**
  621. The object's name during the download according to RFC 2616.
  622. */
  623. @property (nonatomic, copy) NSString * contentDisposition;
  624. /**
  625. The content encoding during the object upload. Checks out RFC2616 for more detail.
  626. */
  627. @property (nonatomic, copy) NSString * contentEncoding;
  628. /**
  629. Specifies the cache control behavior when it's being downloaded.Checks out RFC 2616 for more details.
  630. */
  631. @property (nonatomic, copy) NSString * cacheControl;
  632. /**
  633. Expiration time. Checks out RFC2616 for more information.
  634. */
  635. @property (nonatomic, copy) NSString * expires;
  636. /**
  637. The object's metadata, which start with x-oss-meta-, such as x-oss-meta-location.
  638. Each request can have multiple metadata as long as the total size of all metadata is no bigger than 8KB.
  639. It could include standard headers as well.
  640. */
  641. @property (nonatomic, copy) NSDictionary * objectMeta;
  642. /**
  643. Upload progress callback.
  644. It's called on the background thread.
  645. */
  646. @property (nonatomic, copy) OSSNetworkingUploadProgressBlock uploadProgress;
  647. /**
  648. * the sha1 of content
  649. */
  650. @property (nonatomic, copy) NSString *contentSHA1;
  651. @end
  652. /**
  653. * append object result
  654. */
  655. @interface OSSAppendObjectResult : OSSResult
  656. /**
  657. TODOTODO
  658. ETag (entity tag). It's created for every object when it's created.
  659. For Objects created by PUT, ETag is the MD5 value of the content data. For others, ETag is the UUID of the content.
  660. ETag is used for checking data integrity.
  661. */
  662. @property (nonatomic, copy) NSString * eTag;
  663. /**
  664. Specifies the next starting position. It's essentially the current object size.
  665. This header is included in the successful response or the error response when the start position does not match the object size.
  666. */
  667. @property (nonatomic, assign, readwrite) int64_t xOssNextAppendPosition;
  668. @end
  669. /**
  670. The request of deleting an object.
  671. */
  672. @interface OSSDeleteObjectRequest : OSSRequest
  673. /**
  674. Bucket name
  675. */
  676. @property (nonatomic, copy) NSString * bucketName;
  677. /**
  678. Object object
  679. */
  680. @property (nonatomic, copy) NSString * objectKey;
  681. @end
  682. /**
  683. Result class of deleting an object
  684. */
  685. @interface OSSDeleteObjectResult : OSSResult
  686. @end
  687. /**
  688. Request class of copying an object in OSS.
  689. */
  690. @interface OSSCopyObjectRequest : OSSRequest
  691. /**
  692. Bucket name
  693. */
  694. @property (nonatomic, copy) NSString * bucketName;
  695. /**
  696. Object name
  697. */
  698. @property (nonatomic, copy) NSString * objectKey;
  699. /**
  700. * Source object's address (the caller needs the read permission on this object)
  701. */
  702. @property (nonatomic, copy) NSString * sourceCopyFrom DEPRECATED_MSG_ATTRIBUTE("please use sourceBucketName & sourceObjectKey instead!it will be removed in next version.");
  703. @property (nonatomic, copy) NSString * sourceBucketName;
  704. @property (nonatomic, copy) NSString * sourceObjectKey;
  705. /**
  706. The content type
  707. */
  708. @property (nonatomic, copy) NSString * contentType;
  709. /**
  710. The content's MD5 digest.
  711. It's calculated according to RFC 1864 and encoded in base64.
  712. Though it's optional, it's recommended to turn it on for integrity check.
  713. */
  714. @property (nonatomic, copy) NSString * contentMd5;
  715. /**
  716. The user metadata dictionary, which starts with x-oss-meta-.
  717. The total size of user metadata can be no more than 8KB.
  718. It could include standard http headers as well.
  719. */
  720. @property (nonatomic, copy) NSDictionary * objectMeta;
  721. /**
  722. * the sha1 of content
  723. */
  724. @property (nonatomic, copy) NSString *contentSHA1;
  725. @end
  726. /**
  727. The result class of copying an object
  728. */
  729. @interface OSSCopyObjectResult : OSSResult
  730. /**
  731. The last modified time
  732. */
  733. @property (nonatomic, copy) NSString * lastModifed;
  734. /**
  735. The ETag of the new object.
  736. */
  737. @property (nonatomic, copy) NSString * eTag;
  738. @end
  739. /**
  740. Request class of initiating a multipart upload.
  741. */
  742. @interface OSSInitMultipartUploadRequest : OSSRequest
  743. /**
  744. Bucket name
  745. */
  746. @property (nonatomic, copy) NSString * bucketName;
  747. /**
  748. Object name
  749. */
  750. @property (nonatomic, copy) NSString * objectKey;
  751. /**
  752. Content type
  753. */
  754. @property (nonatomic, copy) NSString * contentType;
  755. /**
  756. The object's download name. Checks out RFC 2616 for more details.
  757. */
  758. @property (nonatomic, copy) NSString * contentDisposition;
  759. /**
  760. The content encoding. Checks out RFC 2616.
  761. */
  762. @property (nonatomic, copy) NSString * contentEncoding;
  763. /**
  764. Specifies the cache control behavior when it's downloaded. Checks out RFC 2616 for more details.
  765. */
  766. @property (nonatomic, copy) NSString * cacheControl;
  767. /**
  768. Expiration time in milliseconds. Checks out RFC 2616 for more details.
  769. */
  770. @property (nonatomic, copy) NSString * expires;
  771. /**
  772. The dictionary of object's custom metadata, which starts with x-oss-meta-.
  773. The total size of user metadata is no more than 8KB.
  774. It could include other standard http headers.
  775. */
  776. @property (nonatomic, copy) NSDictionary * objectMeta;
  777. /**
  778. * When Setting this value to YES , parts will be uploaded in order. Default value is NO.
  779. */
  780. @property (nonatomic, assign) BOOL sequential;
  781. @end
  782. /**
  783. The resutl class of initiating a multipart upload.
  784. */
  785. @interface OSSInitMultipartUploadResult : OSSResult
  786. /**
  787. The upload Id of the multipart upload
  788. */
  789. @property (nonatomic, copy) NSString * uploadId;
  790. @end
  791. /**
  792. The request class of uploading one part.
  793. */
  794. @interface OSSUploadPartRequest : OSSRequest
  795. /**
  796. Bucket name
  797. */
  798. @property (nonatomic, copy) NSString * bucketName;
  799. /**
  800. Object name
  801. */
  802. @property (nonatomic, copy) NSString * objectkey;
  803. /**
  804. Multipart Upload id.
  805. */
  806. @property (nonatomic, copy) NSString * uploadId;
  807. /**
  808. The part number of this part.
  809. */
  810. @property (nonatomic, assign) int partNumber;
  811. /**
  812. The content MD5 value.
  813. It's calculated according to RFC 1864 and encoded in base64.
  814. Though it's optional, it's recommended to turn it on for integrity check.
  815. */
  816. @property (nonatomic, copy) NSString * contentMd5;
  817. /**
  818. The in-memory data to upload from.
  819. */
  820. @property (nonatomic, strong) NSData * uploadPartData;
  821. /**
  822. The local file path to upload from
  823. */
  824. @property (nonatomic, strong) NSURL * uploadPartFileURL;
  825. /**
  826. The upload progress callback.
  827. It runs in background thread (not UI thread);
  828. */
  829. @property (nonatomic, copy) OSSNetworkingUploadProgressBlock uploadPartProgress;
  830. /**
  831. * the sha1 of content
  832. */
  833. @property (nonatomic, copy) NSString *contentSHA1;
  834. @end
  835. /**
  836. The result class of uploading one part.
  837. */
  838. @interface OSSUploadPartResult : OSSResult
  839. @property (nonatomic, copy) NSString * eTag;
  840. @end
  841. /**
  842. The Part information. It's called by CompleteMultipartUpload().
  843. */
  844. @interface OSSPartInfo : NSObject<NSCopying>
  845. /**
  846. The part number in this part upload.
  847. */
  848. @property (nonatomic, assign) int32_t partNum;
  849. /**
  850. ETag value of this part returned by OSS.
  851. */
  852. @property (nonatomic, copy) NSString * eTag;
  853. /**
  854. The part size.
  855. */
  856. @property (nonatomic, assign) int64_t size;
  857. @property (nonatomic, assign) uint64_t crc64;
  858. + (instancetype)partInfoWithPartNum:(int32_t)partNum eTag:(NSString *)eTag size:(int64_t)size __attribute__((deprecated("Use partInfoWithPartNum:eTag:size:crc64: to instead!")));
  859. + (instancetype)partInfoWithPartNum:(int32_t)partNum eTag:(NSString *)eTag size:(int64_t)size crc64:(uint64_t)crc64;
  860. - (NSDictionary *)entityToDictionary;
  861. @end
  862. /**
  863. The request class of completing a multipart upload.
  864. */
  865. @interface OSSCompleteMultipartUploadRequest : OSSRequest
  866. /**
  867. Bucket name
  868. */
  869. @property (nonatomic, copy) NSString * bucketName;
  870. /**
  871. Object name
  872. */
  873. @property (nonatomic, copy) NSString * objectKey;
  874. /**
  875. Multipart upload Id
  876. */
  877. @property (nonatomic, copy) NSString * uploadId;
  878. /**
  879. The content MD5 value.
  880. It's calculated according to RFC 1864 and encoded in base64.
  881. Though it's optional, it's recommended to turn it on for integrity check.
  882. */
  883. @property (nonatomic, copy) NSString * contentMd5;
  884. /**
  885. All parts' information.
  886. */
  887. @property (nonatomic, strong) NSArray * partInfos;
  888. /**
  889. Server side callback parameter
  890. */
  891. @property (nonatomic, copy) NSDictionary * callbackParam;
  892. /**
  893. Callback variables
  894. */
  895. @property (nonatomic, copy) NSDictionary * callbackVar;
  896. /**
  897. The metadata header
  898. */
  899. @property (nonatomic, copy) NSDictionary * completeMetaHeader;
  900. /**
  901. * the sha1 of content
  902. */
  903. @property (nonatomic, copy) NSString *contentSHA1;
  904. @end
  905. /**
  906. The resutl class of completing a multipart upload.
  907. */
  908. @interface OSSCompleteMultipartUploadResult : OSSResult
  909. /**
  910. The object's URL
  911. */
  912. @property (nonatomic, copy) NSString * location;
  913. /**
  914. ETag (entity tag).
  915. It's generated when the object is created.
  916. */
  917. @property (nonatomic, copy) NSString * eTag;
  918. /**
  919. The callback response if the callback is specified.
  920. The resutl class of initiating a multipart upload.
  921. */
  922. @property (nonatomic, copy) NSString * serverReturnJsonString;
  923. @end
  924. /**
  925. The request class of listing all parts that have been uploaded.
  926. */
  927. @interface OSSListPartsRequest : OSSRequest
  928. /**
  929. Bucket name
  930. The request class of uploading one part.*/
  931. @property (nonatomic, copy) NSString * bucketName;
  932. /**
  933. Object name
  934. */
  935. @property (nonatomic, copy) NSString * objectKey;
  936. /**
  937. The multipart upload Id.
  938. */
  939. @property (nonatomic, copy) NSString * uploadId;
  940. /**
  941. The max part count to return
  942. */
  943. @property (nonatomic, assign) int maxParts;
  944. /**
  945. The part number marker filter---only parts whose part number is greater than this value will be returned.
  946. */
  947. @property (nonatomic, assign) int partNumberMarker;
  948. @end
  949. /**
  950. The result class of listing uploaded parts.
  951. */
  952. @interface OSSListPartsResult : OSSResult
  953. /**
  954. The next part number marker. If the response does not include all data, this header specifies what's the start point for the next list call.
  955. */
  956. @property (nonatomic, assign) int nextPartNumberMarker;
  957. /**
  958. The max parts count to return.
  959. */
  960. @property (nonatomic, assign) int maxParts;
  961. /**
  962. Flag of truncated data in the response. If it's true, it means there're more data to come.
  963. If it's false, it means all data have been returned.
  964. */
  965. @property (nonatomic, assign) BOOL isTruncated;
  966. /**
  967. The array of the part information.
  968. */
  969. @property (nonatomic, strong, nullable) NSArray * parts;
  970. @end
  971. /**
  972. The request class of listing all multipart uploads.
  973. */
  974. @interface OSSListMultipartUploadsRequest : OSSRequest
  975. /**
  976. Bucket name.
  977. */
  978. @property (nonatomic, copy) NSString * bucketName;
  979. /**
  980. The delimiter.
  981. */
  982. @property (nonatomic, copy) NSString * delimiter;
  983. /**
  984. The prefix.
  985. */
  986. @property (nonatomic, copy) NSString * prefix;
  987. /**
  988. The max number of uploads.
  989. */
  990. @property (nonatomic, assign) int32_t maxUploads;
  991. /**
  992. The key marker filter.
  993. */
  994. @property (nonatomic, copy) NSString * keyMarker;
  995. /**
  996. The upload Id marker.
  997. */
  998. @property (nonatomic, copy) NSString * uploadIdMarker;
  999. /**
  1000. The encoding type of the object in the response body.
  1001. */
  1002. @property (nonatomic, copy) NSString * encodingType;
  1003. @end
  1004. /**
  1005. The result class of listing multipart uploads.
  1006. */
  1007. @interface OSSListMultipartUploadsResult : OSSResult
  1008. /**
  1009. Bucket name
  1010. */
  1011. @property (nonatomic, copy) NSString * bucketName;
  1012. /**
  1013. The marker filter of the objects returned---all objects returned are greater than this marker in lexicographic order.
  1014. */
  1015. @property (nonatomic, copy) NSString * keyMarker;
  1016. /**
  1017. The delimiter to differentiate the folder object and file object.
  1018. For object whose name ends with the delimiter, then it's treated as folder or common prefixes.
  1019. */
  1020. @property (nonatomic, copy) NSString * delimiter;
  1021. /**
  1022. The prefix of the objects returned----the returned objects must have this prefix.
  1023. */
  1024. @property (nonatomic, copy) NSString * prefix;
  1025. /**
  1026. The upload Id marker.
  1027. */
  1028. @property (nonatomic, copy) NSString * uploadIdMarker;
  1029. /**
  1030. The max entries to return. By default it's 100 and it could be up to 1000.
  1031. */
  1032. @property (nonatomic, assign) int32_t maxUploads;
  1033. /**
  1034. If not all results are returned this time, the response request includes the NextKeyMarker element to indicate the value of KeyMarker in the next request.
  1035. */
  1036. @property (nonatomic, copy) NSString * nextKeyMarker;
  1037. /**
  1038. If not all results are returned this time, the response request includes the NextUploadMarker element to indicate the value of UploadMarker in the next request.
  1039. */
  1040. @property (nonatomic, copy) NSString * nextUploadIdMarker;
  1041. /**
  1042. Flag of truncated result. If it's truncated, it means there's more entries to return.
  1043. */
  1044. @property (nonatomic, assign) BOOL isTruncated;
  1045. @property (nonatomic, strong, nullable) NSArray * uploads;
  1046. /**
  1047. The arrary of common prefixes. Each element is one common prefix.
  1048. */
  1049. @property (nonatomic, strong) NSArray * commonPrefixes;
  1050. @end
  1051. /**
  1052. Request to abort a multipart upload
  1053. */
  1054. @interface OSSAbortMultipartUploadRequest : OSSRequest
  1055. /**
  1056. Bucket name
  1057. */
  1058. @property (nonatomic, copy) NSString * bucketName;
  1059. /**
  1060. Object name
  1061. */
  1062. @property (nonatomic, copy) NSString * objectKey;
  1063. /**
  1064. The multipart upload Id.
  1065. */
  1066. @property (nonatomic, copy) NSString * uploadId;
  1067. @end
  1068. /**
  1069. The result class of aborting a multipart upload
  1070. */
  1071. @interface OSSAbortMultipartUploadResult : OSSResult
  1072. @end
  1073. /**
  1074. The request class of multipart upload.
  1075. */
  1076. @interface OSSMultipartUploadRequest : OSSRequest
  1077. /**
  1078. The upload Id
  1079. */
  1080. @property (nonatomic, copy) NSString * uploadId;
  1081. /**
  1082. Bucket name
  1083. */
  1084. @property (nonatomic, copy) NSString * bucketName;
  1085. /**
  1086. Object object
  1087. */
  1088. @property (nonatomic, copy) NSString * objectKey;
  1089. /**
  1090. The local file path to upload from.
  1091. */
  1092. @property (nonatomic, strong) NSURL * uploadingFileURL;
  1093. /**
  1094. The part size, minimal value is 100KB.
  1095. */
  1096. @property (nonatomic, assign) NSUInteger partSize;
  1097. /**
  1098. Upload progress callback.
  1099. It runs at the background thread (not UI thread).
  1100. */
  1101. @property (nonatomic, copy) OSSNetworkingUploadProgressBlock uploadProgress;
  1102. /**
  1103. The callback parmeters
  1104. */
  1105. @property (nonatomic, copy) NSDictionary * callbackParam;
  1106. /**
  1107. The callback variables
  1108. */
  1109. @property (nonatomic, copy) NSDictionary * callbackVar;
  1110. /**
  1111. Content type
  1112. */
  1113. @property (nonatomic, copy) NSString * contentType;
  1114. /**
  1115. The metadata header
  1116. */
  1117. @property (nonatomic, copy) NSDictionary * completeMetaHeader;
  1118. /**
  1119. * the sha1 of content
  1120. */
  1121. @property (nonatomic, copy) NSString *contentSHA1;
  1122. /**
  1123. * the md5 of content
  1124. */
  1125. @property (nonatomic, copy) NSString *md5String;
  1126. - (void)cancel;
  1127. @end
  1128. /**
  1129. The request class of resumable upload.
  1130. */
  1131. @interface OSSResumableUploadRequest : OSSMultipartUploadRequest
  1132. /**
  1133. directory path about create record uploadId file
  1134. */
  1135. @property (nonatomic, copy) NSString * recordDirectoryPath;
  1136. /**
  1137. need or not delete uploadId with cancel
  1138. */
  1139. @property (nonatomic, assign) BOOL deleteUploadIdOnCancelling;
  1140. /**
  1141. All running children requests
  1142. */
  1143. @property (atomic, weak) OSSRequest * runningChildrenRequest;
  1144. @end
  1145. /**
  1146. The result class of resumable uploading
  1147. */
  1148. @interface OSSResumableUploadResult : OSSResult
  1149. /**
  1150. The callback response, if the callback is specified.
  1151. */
  1152. @property (nonatomic, copy) NSString * serverReturnJsonString;
  1153. @end
  1154. /**
  1155. for more information,Please refer to the link https://help.aliyun.com/document_detail/31989.html
  1156. */
  1157. @interface OSSCallBackRequest : OSSRequest
  1158. @property (nonatomic, copy) NSString *bucketName;
  1159. @property (nonatomic, copy) NSString *objectName;
  1160. /**
  1161. The callback parameters.when you set this value,there are required params as below:
  1162. {
  1163. "callbackUrl": xxx
  1164. "callbackBody": xxx
  1165. }
  1166. */
  1167. @property (nonatomic, copy) NSDictionary *callbackParam;
  1168. /**
  1169. The callback variables.
  1170. */
  1171. @property (nonatomic, copy) NSDictionary *callbackVar;
  1172. @end
  1173. @interface OSSCallBackResult : OSSResult
  1174. @property (nonatomic, copy) NSDictionary *serverReturnXML;
  1175. /**
  1176. If the callback is specified, this is the callback response result.
  1177. */
  1178. @property (nonatomic, copy) NSString *serverReturnJsonString;
  1179. @end
  1180. /**
  1181. for more information,Please refer to the link https://help.aliyun.com/document_detail/55811.html
  1182. */
  1183. @interface OSSImagePersistRequest : OSSRequest
  1184. @property (nonatomic, copy) NSString *fromBucket;
  1185. @property (nonatomic, copy) NSString *fromObject;
  1186. @property (nonatomic, copy) NSString *toBucket;
  1187. @property (nonatomic, copy) NSString *toObject;
  1188. @property (nonatomic, copy) NSString *action;
  1189. @end
  1190. @interface OSSImagePersistResult : OSSResult
  1191. @end
  1192. NS_ASSUME_NONNULL_END