aliyun-oss-react-native

OSSModel.h 35KB

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