FIRStorageMetadata.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. /*
  2. * Copyright 2017 Google
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. #import <Foundation/Foundation.h>
  17. #import "FIRStorageSwiftNameSupport.h"
  18. @class FIRStorageReference;
  19. NS_ASSUME_NONNULL_BEGIN
  20. /**
  21. * Class which represents the metadata on an object in Firebase Storage. This metadata is
  22. * returned on successful operations, and can be used to retrieve download URLs, content types,
  23. * and a FIRStorage reference to the object in question. Full documentation can be found at the GCS
  24. * Objects#resource docs.
  25. * @see https://cloud.google.com/storage/docs/json_api/v1/objects#resource
  26. */
  27. FIR_SWIFT_NAME(StorageMetadata)
  28. @interface FIRStorageMetadata : NSObject<NSCopying>
  29. /**
  30. * The name of the bucket containing this object.
  31. */
  32. @property(copy, nonatomic, readonly) NSString *bucket;
  33. /**
  34. * Cache-Control directive for the object data.
  35. */
  36. @property(copy, nonatomic, nullable) NSString *cacheControl;
  37. /**
  38. * Content-Disposition of the object data.
  39. */
  40. @property(copy, nonatomic, nullable) NSString *contentDisposition;
  41. /**
  42. * Content-Encoding of the object data.
  43. */
  44. @property(copy, nonatomic, nullable) NSString *contentEncoding;
  45. /**
  46. * Content-Language of the object data.
  47. */
  48. @property(copy, nonatomic, nullable) NSString *contentLanguage;
  49. /**
  50. * Content-Type of the object data.
  51. */
  52. @property(copy, nonatomic, nullable) NSString *contentType;
  53. /**
  54. * The content generation of this object. Used for object versioning.
  55. */
  56. @property(readonly) int64_t generation;
  57. /**
  58. * User-provided metadata, in key/value pairs.
  59. */
  60. @property(copy, nonatomic, nullable) NSDictionary<NSString *, NSString *> *customMetadata;
  61. /**
  62. * The version of the metadata for this object at this generation. Used
  63. * for preconditions and for detecting changes in metadata. A metageneration number is only
  64. * meaningful in the context of a particular generation of a particular object.
  65. */
  66. @property(readonly) int64_t metageneration;
  67. /**
  68. * The name of this object, in gs://bucket/path/to/object.txt, this is object.txt.
  69. */
  70. @property(copy, nonatomic, readonly, nullable) NSString *name;
  71. /**
  72. * The full path of this object, in gs://bucket/path/to/object.txt, this is path/to/object.txt.
  73. */
  74. @property(copy, nonatomic, readonly, nullable) NSString *path;
  75. /**
  76. * Content-Length of the data in bytes.
  77. */
  78. @property(readonly) int64_t size;
  79. /**
  80. * The creation time of the object in RFC 3339 format.
  81. */
  82. @property(copy, nonatomic, readonly, nullable) NSDate *timeCreated;
  83. /**
  84. * The modification time of the object metadata in RFC 3339 format.
  85. */
  86. @property(copy, nonatomic, readonly, nullable) NSDate *updated;
  87. /**
  88. * A reference to the object in Firebase Storage.
  89. */
  90. @property(strong, nonatomic, readonly, nullable) FIRStorageReference *storageReference;
  91. /**
  92. * An array containing all download URLs available for the object.
  93. */
  94. @property(strong, nonatomic, readonly, nullable) NSArray<NSURL *> *downloadURLs;
  95. /**
  96. * Creates an instanece of FIRStorageMetadata from the contents of a dictionary.
  97. * @return An instance of FIRStorageMetadata that represents the contents of a dictionary.
  98. */
  99. - (nullable instancetype)initWithDictionary:(NSDictionary <NSString *, id>*)dictionary
  100. NS_DESIGNATED_INITIALIZER;
  101. /**
  102. * Creates an NSDictionary from the contents of the metadata.
  103. * @return An NSDictionary that represents the contents of the metadata.
  104. */
  105. - (NSDictionary <NSString *, id>*)dictionaryRepresentation;
  106. /**
  107. * Determines if the current metadata represents a "file".
  108. */
  109. @property(readonly, getter=isFile) BOOL file;
  110. /**
  111. * Determines if the current metadata represents a "folder".
  112. */
  113. @property(readonly, getter=isFolder) BOOL folder;
  114. /**
  115. * Retrieves a download URL for the given object, or nil if none exist.
  116. * Note that if there are many valid download tokens, this will always return the first
  117. * valid token created.
  118. */
  119. - (nullable NSURL *)downloadURL;
  120. @end
  121. NS_ASSUME_NONNULL_END