azure-storage 0.13.0.preview → 0.14.0.preview
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/azure/storage.rb +14 -13
- data/lib/azure/storage/autoload.rb +31 -31
- data/lib/azure/storage/blob/append.rb +43 -41
- data/lib/azure/storage/blob/blob.rb +150 -147
- data/lib/azure/storage/blob/blob_service.rb +186 -184
- data/lib/azure/storage/blob/block.rb +56 -56
- data/lib/azure/storage/blob/container.rb +93 -92
- data/lib/azure/storage/blob/page.rb +187 -104
- data/lib/azure/storage/blob/serialization.rb +32 -18
- data/lib/azure/storage/client.rb +18 -17
- data/lib/azure/storage/client_options.rb +192 -193
- data/lib/azure/storage/client_options_error.rb +5 -5
- data/lib/azure/storage/configurable.rb +39 -39
- data/lib/azure/storage/core.rb +6 -4
- data/lib/azure/storage/core/auth/shared_access_signature.rb +5 -3
- data/lib/azure/storage/core/auth/shared_access_signature_generator.rb +34 -33
- data/lib/azure/storage/core/auth/shared_access_signature_signer.rb +5 -5
- data/lib/azure/storage/core/auth/shared_key.rb +17 -15
- data/lib/azure/storage/core/autoload.rb +15 -13
- data/lib/azure/storage/core/error.rb +3 -1
- data/lib/azure/storage/core/filter/exponential_retry_filter.rb +13 -11
- data/lib/azure/storage/core/filter/linear_retry_filter.rb +10 -8
- data/lib/azure/storage/core/filter/retry_filter.rb +30 -29
- data/lib/azure/storage/core/http_client.rb +18 -16
- data/lib/azure/storage/core/sr.rb +50 -48
- data/lib/azure/storage/core/utility.rb +19 -17
- data/lib/azure/storage/default.rb +371 -361
- data/lib/azure/storage/file/directory.rb +36 -31
- data/lib/azure/storage/file/file.rb +103 -100
- data/lib/azure/storage/file/file_service.rb +42 -40
- data/lib/azure/storage/file/serialization.rb +9 -6
- data/lib/azure/storage/file/share.rb +48 -46
- data/lib/azure/storage/queue/message.rb +3 -1
- data/lib/azure/storage/queue/queue.rb +3 -2
- data/lib/azure/storage/queue/queue_service.rb +152 -151
- data/lib/azure/storage/queue/serialization.rb +7 -5
- data/lib/azure/storage/service/access_policy.rb +3 -1
- data/lib/azure/storage/service/cors.rb +4 -2
- data/lib/azure/storage/service/cors_rule.rb +3 -1
- data/lib/azure/storage/service/enumeration_results.rb +3 -1
- data/lib/azure/storage/service/logging.rb +5 -3
- data/lib/azure/storage/service/metrics.rb +5 -3
- data/lib/azure/storage/service/retention_policy.rb +3 -1
- data/lib/azure/storage/service/serialization.rb +31 -30
- data/lib/azure/storage/service/signed_identifier.rb +5 -4
- data/lib/azure/storage/service/storage_service.rb +33 -32
- data/lib/azure/storage/service/storage_service_properties.rb +6 -4
- data/lib/azure/storage/table/auth/shared_key.rb +9 -8
- data/lib/azure/storage/table/batch.rb +55 -55
- data/lib/azure/storage/table/batch_response.rb +17 -17
- data/lib/azure/storage/table/edmtype.rb +9 -7
- data/lib/azure/storage/table/entity.rb +4 -3
- data/lib/azure/storage/table/guid.rb +3 -1
- data/lib/azure/storage/table/query.rb +17 -19
- data/lib/azure/storage/table/serialization.rb +14 -12
- data/lib/azure/storage/table/table_service.rb +79 -80
- data/lib/azure/storage/version.rb +7 -5
- metadata +2 -2
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
#-------------------------------------------------------------------------
|
2
4
|
# # Copyright (c) Microsoft and contributors. All rights reserved.
|
3
5
|
#
|
@@ -21,12 +23,12 @@
|
|
21
23
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
22
24
|
# THE SOFTWARE.
|
23
25
|
#--------------------------------------------------------------------------
|
24
|
-
require
|
26
|
+
require "azure/storage/file/serialization"
|
25
27
|
|
26
28
|
module Azure::Storage::File
|
27
29
|
module Directory
|
28
30
|
include Azure::Storage::Service
|
29
|
-
|
31
|
+
|
30
32
|
class Directory
|
31
33
|
def initialize
|
32
34
|
@properties = {}
|
@@ -53,6 +55,8 @@ module Azure::Storage::File
|
|
53
55
|
#
|
54
56
|
# Accepted key/value pairs in options parameter are:
|
55
57
|
#
|
58
|
+
# * +:prefix+ - String. Filters the results to return only directories and files
|
59
|
+
# whose name begins with the specified prefix. (optional)
|
56
60
|
# * +:marker+ - String. An identifier the specifies the portion of the
|
57
61
|
# list to be returned. This value comes from the property
|
58
62
|
# Azure::Service::EnumerationResults.continuation_token when there
|
@@ -68,19 +72,20 @@ module Azure::Storage::File
|
|
68
72
|
#
|
69
73
|
# * +:timeout+ - Integer. A timeout in seconds.
|
70
74
|
#
|
71
|
-
# * +:request_id+ - String. Provides a client-generated, opaque value with a 1 KB character limit that is recorded
|
75
|
+
# * +:request_id+ - String. Provides a client-generated, opaque value with a 1 KB character limit that is recorded
|
72
76
|
# in the analytics logs when storage analytics logging is enabled.
|
73
77
|
#
|
74
78
|
# See: https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/list-directories-and-files
|
75
79
|
#
|
76
80
|
# Returns an Azure::Service::EnumerationResults
|
77
81
|
#
|
78
|
-
def list_directories_and_files(share, directory_path, options={})
|
79
|
-
query = {
|
82
|
+
def list_directories_and_files(share, directory_path, options = {})
|
83
|
+
query = { "comp" => "list" }
|
80
84
|
unless options.nil?
|
81
|
-
StorageService.with_query query,
|
82
|
-
StorageService.with_query query,
|
83
|
-
StorageService.with_query query,
|
85
|
+
StorageService.with_query query, "marker", options[:marker]
|
86
|
+
StorageService.with_query query, "maxresults", options[:max_results].to_s if options[:max_results]
|
87
|
+
StorageService.with_query query, "timeout", options[:timeout].to_s if options[:timeout]
|
88
|
+
StorageService.with_query query, "prefix", options[:prefix].to_s if options[:prefix]
|
84
89
|
end
|
85
90
|
|
86
91
|
uri = directory_uri(share, directory_path, query)
|
@@ -107,16 +112,16 @@ module Azure::Storage::File
|
|
107
112
|
# Accepted key/value pairs in options parameter are:
|
108
113
|
# * +:metadata+ - Hash. User defined metadata for the share (optional).
|
109
114
|
# * +:timeout+ - Integer. A timeout in seconds.
|
110
|
-
# * +:request_id+ - String. Provides a client-generated, opaque value with a 1 KB character limit that is recorded
|
115
|
+
# * +:request_id+ - String. Provides a client-generated, opaque value with a 1 KB character limit that is recorded
|
111
116
|
# in the analytics logs when storage analytics logging is enabled.
|
112
117
|
#
|
113
118
|
# See https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/create-directory
|
114
119
|
#
|
115
120
|
# Returns a Directory
|
116
|
-
def create_directory(share, directory_path, options={})
|
121
|
+
def create_directory(share, directory_path, options = {})
|
117
122
|
# Query
|
118
|
-
query = {
|
119
|
-
query[
|
123
|
+
query = {}
|
124
|
+
query["timeout"] = options[:timeout].to_s if options[:timeout]
|
120
125
|
|
121
126
|
# Scheme + path
|
122
127
|
uri = directory_uri(share, directory_path, query)
|
@@ -149,16 +154,16 @@ module Azure::Storage::File
|
|
149
154
|
#
|
150
155
|
# Accepted key/value pairs in options parameter are:
|
151
156
|
# * +:timeout+ - Integer. A timeout in seconds.
|
152
|
-
# * +:request_id+ - String. Provides a client-generated, opaque value with a 1 KB character limit that is recorded
|
157
|
+
# * +:request_id+ - String. Provides a client-generated, opaque value with a 1 KB character limit that is recorded
|
153
158
|
# in the analytics logs when storage analytics logging is enabled.
|
154
159
|
#
|
155
160
|
# See https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/get-directory-properties
|
156
161
|
#
|
157
162
|
# Returns a Directory
|
158
|
-
def get_directory_properties(share, directory_path, options={})
|
163
|
+
def get_directory_properties(share, directory_path, options = {})
|
159
164
|
# Query
|
160
|
-
query = {
|
161
|
-
query[
|
165
|
+
query = {}
|
166
|
+
query["timeout"] = options[:timeout].to_s if options[:timeout]
|
162
167
|
|
163
168
|
# Call
|
164
169
|
response = call(:get, directory_uri(share, directory_path, query), nil, {}, options)
|
@@ -181,20 +186,20 @@ module Azure::Storage::File
|
|
181
186
|
#
|
182
187
|
# Accepted key/value pairs in options parameter are:
|
183
188
|
# * +:timeout+ - Integer. A timeout in seconds.
|
184
|
-
# * +:request_id+ - String. Provides a client-generated, opaque value with a 1 KB character limit that is recorded
|
189
|
+
# * +:request_id+ - String. Provides a client-generated, opaque value with a 1 KB character limit that is recorded
|
185
190
|
# in the analytics logs when storage analytics logging is enabled.
|
186
191
|
#
|
187
192
|
# See https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/delete-directory
|
188
193
|
#
|
189
194
|
# Returns nil on success
|
190
|
-
def delete_directory(share, directory_path, options={})
|
195
|
+
def delete_directory(share, directory_path, options = {})
|
191
196
|
# Query
|
192
|
-
query = {
|
193
|
-
query[
|
197
|
+
query = {}
|
198
|
+
query["timeout"] = options[:timeout].to_s if options[:timeout]
|
194
199
|
|
195
200
|
# Call
|
196
201
|
call(:delete, directory_uri(share, directory_path, query), nil, {}, options)
|
197
|
-
|
202
|
+
|
198
203
|
# result
|
199
204
|
nil
|
200
205
|
end
|
@@ -211,16 +216,16 @@ module Azure::Storage::File
|
|
211
216
|
#
|
212
217
|
# Accepted key/value pairs in options parameter are:
|
213
218
|
# * +:timeout+ - Integer. A timeout in seconds.
|
214
|
-
# * +:request_id+ - String. Provides a client-generated, opaque value with a 1 KB character limit that is recorded
|
219
|
+
# * +:request_id+ - String. Provides a client-generated, opaque value with a 1 KB character limit that is recorded
|
215
220
|
# in the analytics logs when storage analytics logging is enabled.
|
216
221
|
#
|
217
222
|
# See https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/get-directory-metadata
|
218
223
|
#
|
219
224
|
# Returns a Directory
|
220
|
-
def get_directory_metadata(share, directory_path, options={})
|
225
|
+
def get_directory_metadata(share, directory_path, options = {})
|
221
226
|
# Query
|
222
|
-
query = {
|
223
|
-
query[
|
227
|
+
query = { "comp" => "metadata" }
|
228
|
+
query["timeout"] = options[:timeout].to_s if options[:timeout]
|
224
229
|
|
225
230
|
# Call
|
226
231
|
response = call(:get, directory_uri(share, directory_path, query), nil, {}, options)
|
@@ -244,16 +249,16 @@ module Azure::Storage::File
|
|
244
249
|
#
|
245
250
|
# Accepted key/value pairs in options parameter are:
|
246
251
|
# * +:timeout+ - Integer. A timeout in seconds.
|
247
|
-
# * +:request_id+ - String. Provides a client-generated, opaque value with a 1 KB character limit that is recorded
|
252
|
+
# * +:request_id+ - String. Provides a client-generated, opaque value with a 1 KB character limit that is recorded
|
248
253
|
# in the analytics logs when storage analytics logging is enabled.
|
249
254
|
#
|
250
255
|
# See https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/set-directory-metadata
|
251
256
|
#
|
252
257
|
# Returns nil on success
|
253
|
-
def set_directory_metadata(share, directory_path, metadata, options={})
|
258
|
+
def set_directory_metadata(share, directory_path, metadata, options = {})
|
254
259
|
# Query
|
255
|
-
query = {
|
256
|
-
query[
|
260
|
+
query = { "comp" => "metadata" }
|
261
|
+
query["timeout"] = options[:timeout].to_s if options[:timeout]
|
257
262
|
|
258
263
|
# Headers
|
259
264
|
headers = StorageService.common_headers
|
@@ -261,8 +266,8 @@ module Azure::Storage::File
|
|
261
266
|
|
262
267
|
# Call
|
263
268
|
call(:put, directory_uri(share, directory_path, query), nil, headers, options)
|
264
|
-
|
269
|
+
|
265
270
|
# Result
|
266
271
|
nil
|
267
272
|
end
|
268
|
-
end
|
273
|
+
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
#-------------------------------------------------------------------------
|
2
4
|
# # Copyright (c) Microsoft and contributors. All rights reserved.
|
3
5
|
#
|
@@ -21,11 +23,11 @@
|
|
21
23
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
22
24
|
# THE SOFTWARE.
|
23
25
|
#--------------------------------------------------------------------------
|
24
|
-
require
|
26
|
+
require "azure/storage/file/serialization"
|
25
27
|
|
26
28
|
module Azure::Storage::File
|
27
29
|
include Azure::Storage::Service
|
28
|
-
|
30
|
+
|
29
31
|
class File
|
30
32
|
def initialize
|
31
33
|
@properties = {}
|
@@ -64,38 +66,38 @@ module Azure::Storage::File
|
|
64
66
|
# * +:content_language+ - String. Content language for the file. Will be saved with file.
|
65
67
|
# * +:content_md5+ - String. Content MD5 for the file. Will be saved with file.
|
66
68
|
# * +:cache_control+ - String. Cache control for the file. Will be saved with file.
|
67
|
-
# * +:content_disposition+ - String. Conveys additional information about how to process the response payload,
|
69
|
+
# * +:content_disposition+ - String. Conveys additional information about how to process the response payload,
|
68
70
|
# and also can be used to attach additional metadata
|
69
71
|
# * +:metadata+ - Hash. Custom metadata values to store with the file.
|
70
72
|
# * +:timeout+ - Integer. A timeout in seconds.
|
71
|
-
# * +:request_id+ - String. Provides a client-generated, opaque value with a 1 KB character limit that is recorded
|
73
|
+
# * +:request_id+ - String. Provides a client-generated, opaque value with a 1 KB character limit that is recorded
|
72
74
|
# in the analytics logs when storage analytics logging is enabled.
|
73
75
|
#
|
74
76
|
# See https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/create-file
|
75
77
|
#
|
76
78
|
# Returns a File
|
77
|
-
def create_file(share, directory_path, file, length, options={})
|
78
|
-
query = {
|
79
|
-
StorageService.with_query query,
|
79
|
+
def create_file(share, directory_path, file, length, options = {})
|
80
|
+
query = {}
|
81
|
+
StorageService.with_query query, "timeout", options[:timeout].to_s if options[:timeout]
|
80
82
|
|
81
83
|
uri = file_uri(share, directory_path, file, query)
|
82
84
|
|
83
85
|
headers = StorageService.common_headers
|
84
86
|
|
85
87
|
# set x-ms-type to file
|
86
|
-
StorageService.with_header headers,
|
88
|
+
StorageService.with_header headers, "x-ms-type", "file"
|
87
89
|
|
88
90
|
# ensure content-length is 0 and x-ms-content-length is the file length
|
89
|
-
StorageService.with_header headers,
|
90
|
-
StorageService.with_header headers,
|
91
|
+
StorageService.with_header headers, "Content-Length", 0.to_s
|
92
|
+
StorageService.with_header headers, "x-ms-content-length", length.to_s
|
91
93
|
|
92
94
|
# set the rest of the optional headers
|
93
|
-
StorageService.with_header headers,
|
94
|
-
StorageService.with_header headers,
|
95
|
-
StorageService.with_header headers,
|
96
|
-
StorageService.with_header headers,
|
97
|
-
StorageService.with_header headers,
|
98
|
-
StorageService.with_header headers,
|
95
|
+
StorageService.with_header headers, "x-ms-content-type", options[:content_type]
|
96
|
+
StorageService.with_header headers, "x-ms-content-encoding", options[:content_encoding]
|
97
|
+
StorageService.with_header headers, "x-ms-content-language", options[:content_language]
|
98
|
+
StorageService.with_header headers, "x-ms-content-md5", options[:content_md5]
|
99
|
+
StorageService.with_header headers, "x-ms-cache-control", options[:cache_control]
|
100
|
+
StorageService.with_header headers, "x-ms-content-disposition", options[:content_disposition]
|
99
101
|
|
100
102
|
StorageService.add_metadata_to_headers options[:metadata], headers
|
101
103
|
|
@@ -125,27 +127,28 @@ module Azure::Storage::File
|
|
125
127
|
# * +:get_content_md5+ - Boolean. Return the MD5 hash for the range. This option only valid if
|
126
128
|
# start_range and end_range are specified. (optional)
|
127
129
|
# * +:timeout+ - Integer. A timeout in seconds.
|
128
|
-
# * +:request_id+ - String. Provides a client-generated, opaque value with a 1 KB character limit that is recorded
|
130
|
+
# * +:request_id+ - String. Provides a client-generated, opaque value with a 1 KB character limit that is recorded
|
129
131
|
# in the analytics logs when storage analytics logging is enabled.
|
130
132
|
#
|
131
133
|
# See https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/get-file
|
132
134
|
#
|
133
135
|
# Returns a File and the file body
|
134
|
-
def get_file(share, directory_path, file, options={})
|
135
|
-
query = {
|
136
|
-
StorageService.with_query query,
|
136
|
+
def get_file(share, directory_path, file, options = {})
|
137
|
+
query = {}
|
138
|
+
StorageService.with_query query, "timeout", options[:timeout].to_s if options[:timeout]
|
137
139
|
uri = file_uri(share, directory_path, file, query)
|
138
140
|
|
139
141
|
headers = StorageService.common_headers
|
140
|
-
options[:start_range] = 0 if options[:end_range]
|
142
|
+
options[:start_range] = 0 if options[:end_range] && (not options[:start_range])
|
141
143
|
if options[:start_range]
|
142
|
-
StorageService.with_header headers,
|
143
|
-
StorageService.with_header headers,
|
144
|
+
StorageService.with_header headers, "x-ms-range", "bytes=#{options[:start_range]}-#{options[:end_range]}"
|
145
|
+
StorageService.with_header headers, "x-ms-range-get-content-md5", "true" if options[:get_content_md5]
|
144
146
|
end
|
145
147
|
|
146
148
|
response = call(:get, uri, nil, headers, options)
|
147
149
|
result = Serialization.file_from_headers(response.headers)
|
148
150
|
result.name = file
|
151
|
+
|
149
152
|
return result, response.body
|
150
153
|
end
|
151
154
|
|
@@ -162,18 +165,18 @@ module Azure::Storage::File
|
|
162
165
|
#
|
163
166
|
# Accepted key/value pairs in options parameter are:
|
164
167
|
# * +:timeout+ - Integer. A timeout in seconds.
|
165
|
-
# * +:request_id+ - String. Provides a client-generated, opaque value with a 1 KB character limit that is recorded
|
168
|
+
# * +:request_id+ - String. Provides a client-generated, opaque value with a 1 KB character limit that is recorded
|
166
169
|
# in the analytics logs when storage analytics logging is enabled.
|
167
170
|
#
|
168
171
|
# See https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/get-file-properties
|
169
172
|
#
|
170
173
|
# Returns a File
|
171
|
-
def get_file_properties(share, directory_path, file, options={})
|
172
|
-
query = {
|
173
|
-
StorageService.with_query query,
|
174
|
+
def get_file_properties(share, directory_path, file, options = {})
|
175
|
+
query = {}
|
176
|
+
StorageService.with_query query, "timeout", options[:timeout].to_s if options[:timeout]
|
174
177
|
|
175
178
|
headers = StorageService.common_headers
|
176
|
-
|
179
|
+
|
177
180
|
uri = file_uri(share, directory_path, file, query)
|
178
181
|
|
179
182
|
response = call(:head, uri, nil, headers, options)
|
@@ -200,33 +203,33 @@ module Azure::Storage::File
|
|
200
203
|
# * +:content_language+ - String. Content language for the file. Will be saved with file.
|
201
204
|
# * +:content_md5+ - String. Content MD5 for the file. Will be saved with file.
|
202
205
|
# * +:cache_control+ - String. Cache control for the file. Will be saved with file.
|
203
|
-
# * +:content_disposition+ - String. Conveys additional information about how to process the response payload,
|
206
|
+
# * +:content_disposition+ - String. Conveys additional information about how to process the response payload,
|
204
207
|
# and also can be used to attach additional metadata
|
205
208
|
# * +:content_length+ - Integer. Resizes a file to the specified size. If the specified
|
206
209
|
# value is less than the current size of the file, then all ranges above
|
207
210
|
# the specified value are cleared.
|
208
211
|
# * +:timeout+ - Integer. A timeout in seconds.
|
209
|
-
# * +:request_id+ - String. Provides a client-generated, opaque value with a 1 KB character limit that is recorded
|
212
|
+
# * +:request_id+ - String. Provides a client-generated, opaque value with a 1 KB character limit that is recorded
|
210
213
|
# in the analytics logs when storage analytics logging is enabled.
|
211
214
|
#
|
212
215
|
# See https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/set-file-properties
|
213
216
|
#
|
214
217
|
# Returns nil on success.
|
215
|
-
def set_file_properties(share, directory_path, file, options={})
|
216
|
-
query = {
|
217
|
-
StorageService.with_query query,
|
218
|
+
def set_file_properties(share, directory_path, file, options = {})
|
219
|
+
query = { "comp" => "properties" }
|
220
|
+
StorageService.with_query query, "timeout", options[:timeout].to_s if options[:timeout]
|
218
221
|
uri = file_uri(share, directory_path, file, query)
|
219
222
|
|
220
223
|
headers = StorageService.common_headers
|
221
224
|
|
222
225
|
unless options.empty?
|
223
|
-
StorageService.with_header headers,
|
224
|
-
StorageService.with_header headers,
|
225
|
-
StorageService.with_header headers,
|
226
|
-
StorageService.with_header headers,
|
227
|
-
StorageService.with_header headers,
|
228
|
-
StorageService.with_header headers,
|
229
|
-
StorageService.with_header headers,
|
226
|
+
StorageService.with_header headers, "x-ms-content-type", options[:content_type]
|
227
|
+
StorageService.with_header headers, "x-ms-content-encoding", options[:content_encoding]
|
228
|
+
StorageService.with_header headers, "x-ms-content-language", options[:content_language]
|
229
|
+
StorageService.with_header headers, "x-ms-content-md5", options[:content_md5]
|
230
|
+
StorageService.with_header headers, "x-ms-cache-control", options[:cache_control]
|
231
|
+
StorageService.with_header headers, "x-ms-content-length", options[:content_length].to_s if options[:content_length]
|
232
|
+
StorageService.with_header headers, "x-ms-content-disposition", options[:content_disposition]
|
230
233
|
end
|
231
234
|
|
232
235
|
call(:put, uri, nil, headers, options)
|
@@ -240,8 +243,8 @@ module Azure::Storage::File
|
|
240
243
|
# * +share+ - String. The name of the file share.
|
241
244
|
# * +directory_path+ - String. The path to the directory.
|
242
245
|
# * +file+ - String. The name of the file.
|
243
|
-
# * +size+ - String. The file size. Resizes a file to the specified size.
|
244
|
-
# If the specified value is less than the current size of the file,
|
246
|
+
# * +size+ - String. The file size. Resizes a file to the specified size.
|
247
|
+
# If the specified value is less than the current size of the file,
|
245
248
|
# then all ranges above the specified value are cleared.
|
246
249
|
# * +options+ - Hash. Optional parameters.
|
247
250
|
#
|
@@ -249,14 +252,14 @@ module Azure::Storage::File
|
|
249
252
|
#
|
250
253
|
# Accepted key/value pairs in options parameter are:
|
251
254
|
# * +:timeout+ - Integer. A timeout in seconds.
|
252
|
-
# * +:request_id+ - String. Provides a client-generated, opaque value with a 1 KB character limit that is recorded
|
255
|
+
# * +:request_id+ - String. Provides a client-generated, opaque value with a 1 KB character limit that is recorded
|
253
256
|
# in the analytics logs when storage analytics logging is enabled.
|
254
257
|
#
|
255
258
|
# See https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/set-file-properties
|
256
259
|
#
|
257
260
|
# Returns nil on success.
|
258
|
-
def resize_file(share, directory_path, file, size, options={})
|
259
|
-
options = { :
|
261
|
+
def resize_file(share, directory_path, file, size, options = {})
|
262
|
+
options = { content_length: size }.merge(options)
|
260
263
|
set_file_properties share, directory_path, file, options
|
261
264
|
end
|
262
265
|
|
@@ -278,23 +281,23 @@ module Azure::Storage::File
|
|
278
281
|
# * +:transactional_md5+ - String. An MD5 hash of the content. This hash is used to verify the integrity of the data during transport.
|
279
282
|
# When this header is specified, the storage service checks the hash that has arrived with the one that was sent.
|
280
283
|
# * +:timeout+ - Integer. A timeout in seconds.
|
281
|
-
# * +:request_id+ - String. Provides a client-generated, opaque value with a 1 KB character limit that is recorded
|
284
|
+
# * +:request_id+ - String. Provides a client-generated, opaque value with a 1 KB character limit that is recorded
|
282
285
|
# in the analytics logs when storage analytics logging is enabled.
|
283
|
-
#
|
286
|
+
#
|
284
287
|
# See https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/put-range
|
285
288
|
#
|
286
289
|
# Returns a File
|
287
290
|
#
|
288
|
-
def put_file_range(share, directory_path, file, start_range, end_range=nil, content=nil, options={})
|
289
|
-
query = {
|
290
|
-
StorageService.with_query query,
|
291
|
+
def put_file_range(share, directory_path, file, start_range, end_range = nil, content = nil, options = {})
|
292
|
+
query = { "comp" => "range" }
|
293
|
+
StorageService.with_query query, "timeout", options[:timeout].to_s if options[:timeout]
|
291
294
|
|
292
295
|
uri = file_uri(share, directory_path, file, query)
|
293
296
|
headers = StorageService.common_headers
|
294
|
-
StorageService.with_header headers,
|
295
|
-
StorageService.with_header headers,
|
296
|
-
StorageService.with_header headers,
|
297
|
-
|
297
|
+
StorageService.with_header headers, "Content-MD5", options[:transactional_md5]
|
298
|
+
StorageService.with_header headers, "x-ms-range", "bytes=#{start_range}-#{end_range}"
|
299
|
+
StorageService.with_header headers, "x-ms-write", "update"
|
300
|
+
|
298
301
|
response = call(:put, uri, content, headers, options)
|
299
302
|
|
300
303
|
result = Serialization.file_from_headers(response.headers)
|
@@ -317,22 +320,22 @@ module Azure::Storage::File
|
|
317
320
|
#
|
318
321
|
# Accepted key/value pairs in options parameter are:
|
319
322
|
# * +:timeout+ - Integer. A timeout in seconds.
|
320
|
-
# * +:request_id+ - String. Provides a client-generated, opaque value with a 1 KB character limit that is recorded
|
323
|
+
# * +:request_id+ - String. Provides a client-generated, opaque value with a 1 KB character limit that is recorded
|
321
324
|
# in the analytics logs when storage analytics logging is enabled.
|
322
325
|
#
|
323
326
|
# See https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/put-range
|
324
327
|
#
|
325
328
|
# Returns a File
|
326
|
-
def clear_file_range(share, directory_path, file, start_range, end_range=nil, options={})
|
327
|
-
query = {
|
328
|
-
StorageService.with_query query,
|
329
|
+
def clear_file_range(share, directory_path, file, start_range, end_range = nil, options = {})
|
330
|
+
query = { "comp" => "range" }
|
331
|
+
StorageService.with_query query, "timeout", options[:timeout].to_s if options[:timeout]
|
329
332
|
|
330
|
-
uri =
|
331
|
-
start_range = 0 if !end_range.nil?
|
333
|
+
uri = file_uri(share, directory_path, file, query)
|
334
|
+
start_range = 0 if !end_range.nil? && start_range.nil?
|
332
335
|
|
333
336
|
headers = StorageService.common_headers
|
334
|
-
StorageService.with_header headers,
|
335
|
-
StorageService.with_header headers,
|
337
|
+
StorageService.with_header headers, "x-ms-range", "bytes=#{start_range}-#{end_range}"
|
338
|
+
StorageService.with_header headers, "x-ms-write", "clear"
|
336
339
|
|
337
340
|
response = call(:put, uri, nil, headers, options)
|
338
341
|
|
@@ -356,7 +359,7 @@ module Azure::Storage::File
|
|
356
359
|
# * +:start_range+ - Integer. Position of first byte of the range.
|
357
360
|
# * +:end_range+ - Integer. Position of last byte of of the range.
|
358
361
|
# * +:timeout+ - Integer. A timeout in seconds.
|
359
|
-
# * +:request_id+ - String. Provides a client-generated, opaque value with a 1 KB character limit that is recorded
|
362
|
+
# * +:request_id+ - String. Provides a client-generated, opaque value with a 1 KB character limit that is recorded
|
360
363
|
# in the analytics logs when storage analytics logging is enabled.
|
361
364
|
#
|
362
365
|
# See https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/list-ranges
|
@@ -365,17 +368,17 @@ module Azure::Storage::File
|
|
365
368
|
#
|
366
369
|
# eg. (Azure::Storage::File::File, [ [0, 511], [512, 1024], ... ])
|
367
370
|
#
|
368
|
-
def list_file_ranges(share, directory_path, file, options={})
|
369
|
-
query = {
|
370
|
-
StorageService.with_query query,
|
371
|
+
def list_file_ranges(share, directory_path, file, options = {})
|
372
|
+
query = { "comp" => "rangelist" }
|
373
|
+
StorageService.with_query query, "timeout", options[:timeout].to_s if options[:timeout]
|
371
374
|
|
372
375
|
uri = file_uri(share, directory_path, file, query)
|
373
376
|
|
374
|
-
options[:start_range] = 0 if options[:end_range]
|
377
|
+
options[:start_range] = 0 if options[:end_range] && (not options[:start_range])
|
375
378
|
|
376
379
|
headers = StorageService.common_headers
|
377
|
-
StorageService.with_header headers,
|
378
|
-
|
380
|
+
StorageService.with_header headers, "x-ms-range", "bytes=#{options[:start_range]}-#{options[:end_range]}" if options[:start_range]
|
381
|
+
|
379
382
|
response = call(:get, uri, nil, headers, options)
|
380
383
|
|
381
384
|
result = Serialization.file_from_headers(response.headers)
|
@@ -397,16 +400,16 @@ module Azure::Storage::File
|
|
397
400
|
#
|
398
401
|
# Accepted key/value pairs in options parameter are:
|
399
402
|
# * +:timeout+ - Integer. A timeout in seconds.
|
400
|
-
# * +:request_id+ - String. Provides a client-generated, opaque value with a 1 KB character limit that is recorded
|
403
|
+
# * +:request_id+ - String. Provides a client-generated, opaque value with a 1 KB character limit that is recorded
|
401
404
|
# in the analytics logs when storage analytics logging is enabled.
|
402
405
|
#
|
403
406
|
# See https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/get-file-metadata
|
404
407
|
#
|
405
408
|
# Returns a File
|
406
|
-
def get_file_metadata(share, directory_path, file, options={})
|
409
|
+
def get_file_metadata(share, directory_path, file, options = {})
|
407
410
|
# Query
|
408
|
-
query = {
|
409
|
-
query[
|
411
|
+
query = { "comp" => "metadata" }
|
412
|
+
query["timeout"] = options[:timeout].to_s if options[:timeout]
|
410
413
|
|
411
414
|
# Call
|
412
415
|
response = call(:get, file_uri(share, directory_path, file, query), nil, {}, options)
|
@@ -431,16 +434,16 @@ module Azure::Storage::File
|
|
431
434
|
#
|
432
435
|
# Accepted key/value pairs in options parameter are:
|
433
436
|
# * +:timeout+ - Integer. A timeout in seconds.
|
434
|
-
# * +:request_id+ - String. Provides a client-generated, opaque value with a 1 KB character limit that is recorded
|
437
|
+
# * +:request_id+ - String. Provides a client-generated, opaque value with a 1 KB character limit that is recorded
|
435
438
|
# in the analytics logs when storage analytics logging is enabled.
|
436
439
|
#
|
437
440
|
# See https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/set-file-metadata
|
438
441
|
#
|
439
442
|
# Returns nil on success
|
440
|
-
def set_file_metadata(share, directory_path, file, metadata, options={})
|
443
|
+
def set_file_metadata(share, directory_path, file, metadata, options = {})
|
441
444
|
# Query
|
442
|
-
query = {
|
443
|
-
query[
|
445
|
+
query = { "comp" => "metadata" }
|
446
|
+
query["timeout"] = options[:timeout].to_s if options[:timeout]
|
444
447
|
|
445
448
|
# Headers
|
446
449
|
headers = StorageService.common_headers
|
@@ -448,7 +451,7 @@ module Azure::Storage::File
|
|
448
451
|
|
449
452
|
# Call
|
450
453
|
call(:put, file_uri(share, directory_path, file, query), nil, headers, options)
|
451
|
-
|
454
|
+
|
452
455
|
# Result
|
453
456
|
nil
|
454
457
|
end
|
@@ -466,20 +469,20 @@ module Azure::Storage::File
|
|
466
469
|
#
|
467
470
|
# Accepted key/value pairs in options parameter are:
|
468
471
|
# * +:timeout+ - Integer. A timeout in seconds.
|
469
|
-
# * +:request_id+ - String. Provides a client-generated, opaque value with a 1 KB character limit that is recorded
|
472
|
+
# * +:request_id+ - String. Provides a client-generated, opaque value with a 1 KB character limit that is recorded
|
470
473
|
# in the analytics logs when storage analytics logging is enabled.
|
471
474
|
#
|
472
475
|
# See https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/delete-file2
|
473
476
|
#
|
474
477
|
# Returns nil on success
|
475
|
-
def delete_file(share, directory_path, file, options={})
|
478
|
+
def delete_file(share, directory_path, file, options = {})
|
476
479
|
# Query
|
477
|
-
query = {
|
478
|
-
query[
|
479
|
-
|
480
|
+
query = {}
|
481
|
+
query["timeout"] = options[:timeout].to_s if options[:timeout]
|
482
|
+
|
480
483
|
# Call
|
481
484
|
call(:delete, file_uri(share, directory_path, file, query), nil, {}, options)
|
482
|
-
|
485
|
+
|
483
486
|
# result
|
484
487
|
nil
|
485
488
|
end
|
@@ -502,7 +505,7 @@ module Azure::Storage::File
|
|
502
505
|
# file. If this parameter is specified, the destination file is created with the
|
503
506
|
# specified metadata, and metadata is not copied from the source file.
|
504
507
|
# * +:timeout+ - Integer. A timeout in seconds.
|
505
|
-
# * +:request_id+ - String. Provides a client-generated, opaque value with a 1 KB character limit that is recorded
|
508
|
+
# * +:request_id+ - String. Provides a client-generated, opaque value with a 1 KB character limit that is recorded
|
506
509
|
# in the analytics logs when storage analytics logging is enabled.
|
507
510
|
#
|
508
511
|
# See https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/copy-file
|
@@ -515,17 +518,17 @@ module Azure::Storage::File
|
|
515
518
|
# "success" - The copy completed successfully.
|
516
519
|
# "pending" - The copy is in progress.
|
517
520
|
#
|
518
|
-
def copy_file_from_uri(destination_share, destination_directory_path, destination_file, source_uri, options={})
|
519
|
-
query = {
|
520
|
-
StorageService.with_query query,
|
521
|
+
def copy_file_from_uri(destination_share, destination_directory_path, destination_file, source_uri, options = {})
|
522
|
+
query = {}
|
523
|
+
StorageService.with_query query, "timeout", options[:timeout].to_s if options[:timeout]
|
521
524
|
|
522
525
|
uri = file_uri(destination_share, destination_directory_path, destination_file, query)
|
523
526
|
headers = StorageService.common_headers
|
524
|
-
StorageService.with_header headers,
|
527
|
+
StorageService.with_header headers, "x-ms-copy-source", source_uri
|
525
528
|
StorageService.add_metadata_to_headers options[:metadata], headers unless options.empty?
|
526
529
|
|
527
530
|
response = call(:put, uri, nil, headers, options)
|
528
|
-
return response.headers[
|
531
|
+
return response.headers["x-ms-copy-id"], response.headers["x-ms-copy-status"]
|
529
532
|
end
|
530
533
|
|
531
534
|
# Public: Copies a source file to a destination file within the same storage account.
|
@@ -548,7 +551,7 @@ module Azure::Storage::File
|
|
548
551
|
# file. If this parameter is specified, the destination file is created with the
|
549
552
|
# specified metadata, and metadata is not copied from the source file.
|
550
553
|
# * +:timeout+ - Integer. A timeout in seconds.
|
551
|
-
# * +:request_id+ - String. Provides a client-generated, opaque value with a 1 KB character limit that is recorded
|
554
|
+
# * +:request_id+ - String. Provides a client-generated, opaque value with a 1 KB character limit that is recorded
|
552
555
|
# in the analytics logs when storage analytics logging is enabled.
|
553
556
|
#
|
554
557
|
# See https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/copy-file
|
@@ -561,13 +564,13 @@ module Azure::Storage::File
|
|
561
564
|
# "success" - The copy completed successfully.
|
562
565
|
# "pending" - The copy is in progress.
|
563
566
|
#
|
564
|
-
def copy_file(destination_share, destination_directory_path, destination_file, source_share, source_directory_path, source_file, options={})
|
567
|
+
def copy_file(destination_share, destination_directory_path, destination_file, source_share, source_directory_path, source_file, options = {})
|
565
568
|
source_file_uri = file_uri(source_share, source_directory_path, source_file, {}).to_s
|
566
569
|
|
567
570
|
return copy_file_from_uri(destination_share, destination_directory_path, destination_file, source_file_uri, options)
|
568
571
|
end
|
569
572
|
|
570
|
-
# Public: Aborts a pending Copy File operation and leaves a destination file with zero length and full metadata.
|
573
|
+
# Public: Aborts a pending Copy File operation and leaves a destination file with zero length and full metadata.
|
571
574
|
#
|
572
575
|
# ==== Attributes
|
573
576
|
#
|
@@ -581,22 +584,22 @@ module Azure::Storage::File
|
|
581
584
|
#
|
582
585
|
# Accepted key/value pairs in options parameter are:
|
583
586
|
# * +:timeout+ - Integer. A timeout in seconds.
|
584
|
-
# * +:request_id+ - String. Provides a client-generated, opaque value with a 1 KB character limit that is recorded
|
587
|
+
# * +:request_id+ - String. Provides a client-generated, opaque value with a 1 KB character limit that is recorded
|
585
588
|
# in the analytics logs when storage analytics logging is enabled.
|
586
589
|
#
|
587
590
|
# See https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/abort-copy-file
|
588
591
|
#
|
589
592
|
# Returns nil on success
|
590
|
-
def abort_copy_file(share, directory_path, file, copy_id, options={})
|
591
|
-
query = {
|
592
|
-
StorageService.with_query query,
|
593
|
-
StorageService.with_query query,
|
593
|
+
def abort_copy_file(share, directory_path, file, copy_id, options = {})
|
594
|
+
query = { "comp" => "copy" }
|
595
|
+
StorageService.with_query query, "timeout", options[:timeout].to_s if options[:timeout]
|
596
|
+
StorageService.with_query query, "copyid", copy_id
|
594
597
|
|
595
598
|
uri = file_uri(share, directory_path, file, query);
|
596
599
|
headers = StorageService.common_headers
|
597
|
-
StorageService.with_header headers,
|
600
|
+
StorageService.with_header headers, "x-ms-copy-action", "abort";
|
598
601
|
|
599
602
|
call(:put, uri, nil, headers, options)
|
600
603
|
nil
|
601
604
|
end
|
602
|
-
end
|
605
|
+
end
|