wolf_core 0.1.90 → 0.1.91
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/wolf_core/utils/file_utils.rb +26 -1
- data/lib/wolf_core/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a1f413ca280ec6a3b545b09b41aa3c94ac04ca81dd82f1e5247ddabbd7442613
|
4
|
+
data.tar.gz: 245bcae482df84beb3e960bab0014c35eb6872622957771ee824ee3712de4953
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e0b8d80dad981e4b21daf08f84987824ca85af03b0d138666fb2a6dd25008bbe9b810cf35b576c85a1ab33dcbfa8ce875157544e7579489727508cbbaf18a71b
|
7
|
+
data.tar.gz: ca9b9cf5361617f6a071bcf720b93fdceea0b1ef2d03b19db5af4c67437765d5ec9e8c64b169ac18cbedf142180c501aca99af7c92b194537ce39987e45f3b4f
|
@@ -44,5 +44,30 @@ module WolfCore
|
|
44
44
|
|
45
45
|
log_object "File Deleting Process Finished! (#{files_to_delete.size} files deleted)"
|
46
46
|
end
|
47
|
+
|
48
|
+
def encode_file_to_base64_from_url(url)
|
49
|
+
uri = URI.parse(url)
|
50
|
+
response = Net::HTTP.get_response(uri)
|
51
|
+
raise_service_error({ message: 'Failed to download file', url: url }) unless response.is_a?(Net::HTTPSuccess)
|
52
|
+
|
53
|
+
encoded_file = Base64.strict_encode64(response.body)
|
54
|
+
|
55
|
+
content_disposition = response['content-disposition']
|
56
|
+
|
57
|
+
filename = if content_disposition
|
58
|
+
match = content_disposition.match(/filename="?([^"]+)"?/)
|
59
|
+
match ? match[1] : File.basename(uri.path)
|
60
|
+
else
|
61
|
+
File.basename(uri.path)
|
62
|
+
end
|
63
|
+
log_object filename, title: 'filename is'
|
64
|
+
return { filename: filename, encoded_file: encoded_file }
|
65
|
+
rescue => e
|
66
|
+
raise_service_error({
|
67
|
+
message: 'Failed to encode file url',
|
68
|
+
encode_file_error: { message: e.message, backtrace: e.backtrace },
|
69
|
+
url: url,
|
70
|
+
})
|
71
|
+
end
|
47
72
|
end
|
48
|
-
end
|
73
|
+
end
|
data/lib/wolf_core/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wolf_core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.91
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Javier Roncallo
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-09-
|
11
|
+
date: 2024-09-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|