OSSModel.h 35 KB

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