my-s3-client 0.1.1 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/my_s3/client/version.rb +1 -1
- data/lib/my_s3/client.rb +12 -5
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 2d6b099fd9cd6a4d3966086972fae5aed31a67a8960c5e1f4770da8d04110f8a
|
|
4
|
+
data.tar.gz: 27ddcecec640991eafb1fb3c68443572940f27bf3739902008e03786c1bbe8b0
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 86bd674a691a4ff1663b150dfa8625399b3439d81ced11ca0d52bd1abecb5e79f23a0f0315ca385dc9575492defac9c12f2c190dca3eec6b0a117801bd98bb09
|
|
7
|
+
data.tar.gz: 7961125afb22b46c763020393e5d68f9b9cecc6e70028911a549c9fe95712941fe9a5793a0071f0115f17c120dbd9eaf0d1dbf6ef97a7ead8f4fd5ec004607c0
|
data/lib/my_s3/client/version.rb
CHANGED
data/lib/my_s3/client.rb
CHANGED
|
@@ -73,13 +73,12 @@ module MyS3
|
|
|
73
73
|
request['X-API-Key'] = api_key
|
|
74
74
|
request['Content-Type'] = "multipart/form-data; boundary=#{boundary}"
|
|
75
75
|
request.body = build_my_s3_multipart(boundary, relative_path, filename, file_path)
|
|
76
|
-
|
|
77
76
|
response = http_request(uri, request)
|
|
78
77
|
json = parse_json(response.body)
|
|
79
78
|
return json if response.is_a?(Net::HTTPSuccess) && json['success']
|
|
80
79
|
|
|
81
|
-
|
|
82
|
-
|
|
80
|
+
message = json.dig('error', 'message') || response.body
|
|
81
|
+
raise Error, message
|
|
83
82
|
end
|
|
84
83
|
|
|
85
84
|
def download_file(path:, filename:, target_path: nil)
|
|
@@ -108,8 +107,8 @@ module MyS3
|
|
|
108
107
|
sanitized.split('/').each do |segment|
|
|
109
108
|
begin
|
|
110
109
|
create_folder(path: current, folder_name: segment)
|
|
111
|
-
rescue Error
|
|
112
|
-
raise unless
|
|
110
|
+
rescue Error
|
|
111
|
+
raise unless folder_exists_in_path?(current, segment)
|
|
113
112
|
end
|
|
114
113
|
current = current.empty? ? segment : [current, segment].join('/')
|
|
115
114
|
end
|
|
@@ -218,5 +217,13 @@ module MyS3
|
|
|
218
217
|
fragments.reject!(&:empty?)
|
|
219
218
|
fragments.join('/')
|
|
220
219
|
end
|
|
220
|
+
|
|
221
|
+
def folder_exists_in_path?(path, folder_name)
|
|
222
|
+
listing = list(path: path)
|
|
223
|
+
directories = listing['directories'] || []
|
|
224
|
+
directories.any? { |entry| entry['name'].to_s == folder_name.to_s }
|
|
225
|
+
rescue Error
|
|
226
|
+
false
|
|
227
|
+
end
|
|
221
228
|
end
|
|
222
229
|
end
|