OSSModel.h 36 KB

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