wolf_core 1.0.50 → 1.0.52

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c3381b62135ffb1ee1e6473708cb7c39b6e9cb56852d0082db844dfe10d928ec
4
- data.tar.gz: 03aecbe82ba0f63683d2ec1ca91c49727c6e95be89f340882dcfc3ef9bab8989
3
+ metadata.gz: 7c1e7e387b6115905bde116bf41eacd035566117c54984cc75107d54a5546524
4
+ data.tar.gz: e35f0fa19d1085304258c79eb4d2df57fcbdcfc84b37f525dbf4c2eeb4df30f4
5
5
  SHA512:
6
- metadata.gz: cee10bbe65f246ab589cdde283e33ebea74afeda0a3f246610672e69fda7d0c11f82ca1f34ebb4088c4ed3a7e21fc7d6a0f2017e2fc041ea1603b855c478eb06
7
- data.tar.gz: 32f90a9cb33c6fdec0fc4847338aff5a8d83e735881a046296cb495fe31da2a9097cbf9e7e453439cb55c4d6fa73bd84fcb1835c1745ae8927d923b7979df1ce
6
+ metadata.gz: 1ff850507b14dbae591f32321e88ccea87fbd59cc541ba5a38139eae99719daebdce8f8f9f3f3f929297abb2df3a1d8f8567af5db3930ea1b6bade4dad8b314d
7
+ data.tar.gz: c6721e184873ad8c2eb15bcd8279b8e564eddf317b9b73402dd25361b3334361274f35318cc3b00a9ce9c2c842a98e95a1e0e78c8a32a58ed06a9c4d80aabb32
@@ -83,5 +83,40 @@ module WolfCore
83
83
  File.basename(uri.path)
84
84
  end
85
85
  end
86
+
87
+ def generate_url_from_file(file:, api_key:)
88
+ url = URI.parse("https://www.filestackapi.com/api/store/S3?key=#{api_key}")
89
+ request = Net::HTTP::Post.new(url)
90
+ request["Content-Type"] = "application/octet-stream"
91
+ request.body = file.read
92
+
93
+ response = Net::HTTP.start(url.hostname, url.port, use_ssl: true) do |http|
94
+ http.request(request)
95
+ end
96
+
97
+ parse_json_error = nil
98
+ if response.is_a?(Net::HTTPSuccess)
99
+ begin
100
+ response_body = JSON.parse(response.body)
101
+ rescue => e
102
+ parse_json_error = {
103
+ message: e.message,
104
+ backtrace: e.backtrace,
105
+ }
106
+ end
107
+ return response_body['url'] if response_body['url'].present?
108
+ end
109
+
110
+ raise_service_error({
111
+ message: "Failed to generate url from file",
112
+ url: url,
113
+ file: file,
114
+ form_data: form_data,
115
+ request: request,
116
+ response: response,
117
+ response_body: response.body,
118
+ parse_json_error: parse_json_error,
119
+ })
120
+ end
86
121
  end
87
122
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module WolfCore
4
- VERSION = "1.0.50"
4
+ VERSION = "1.0.52"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wolf_core
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.50
4
+ version: 1.0.52
5
5
  platform: ruby
6
6
  authors:
7
7
  - Javier Roncallo