onlyoffice_s3_wrapper 0.4.0 → 1.0.0
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/onlyoffice_s3_wrapper/version.rb +1 -1
- data/lib/onlyoffice_s3_wrapper.rb +23 -6
- metadata +9 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4f759299fdd77c2713fe455c51d27d341b35ca6eb011ba5fb5672418ac29804d
|
4
|
+
data.tar.gz: 52f1566fa9c5d47f81c7f107537480ec6f5c901955036e4b5186ddb372344c22
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6adf855422c3d44b99a6c357eb680330feb6c9b4644ced8d76173f55b64781fe731ab1e44646c82c511c826ac70d7d373743968340f9973054d9c55a5430732d
|
7
|
+
data.tar.gz: 67c4fcf4192b16197d9d91c9a762424b02286f309cc0073f3bea09f0d94fc81409546130b5d5d505d428b0d1fb3e34ffed62a203349b7c664b8afd0074842ca1
|
@@ -11,6 +11,9 @@ require 'onlyoffice_s3_wrapper/version'
|
|
11
11
|
module OnlyofficeS3Wrapper
|
12
12
|
# Class for working with amazon s3
|
13
13
|
class AmazonS3Wrapper
|
14
|
+
# @return [String] default content type for uploaded files
|
15
|
+
DEFAULT_CONTENT_TYPE = 'binary/octet-stream'
|
16
|
+
|
14
17
|
include PathHelper
|
15
18
|
attr_accessor :s3, :bucket, :download_folder
|
16
19
|
# [String] Amazon key
|
@@ -38,6 +41,16 @@ module OnlyofficeS3Wrapper
|
|
38
41
|
.reject { |file| folder?(file) }
|
39
42
|
end
|
40
43
|
|
44
|
+
# Get list of files from specific folder
|
45
|
+
# Will not use folder name as prefix, will always try to look at folder
|
46
|
+
# with exact specified name
|
47
|
+
# @param [String] folder to get files
|
48
|
+
# @return [Array<Object>] result set
|
49
|
+
def files_from_folder(folder = nil)
|
50
|
+
folder = "#{folder}/" unless folder.end_with?('/')
|
51
|
+
get_files_by_prefix(folder)
|
52
|
+
end
|
53
|
+
|
41
54
|
# param [String] prefix
|
42
55
|
# return [Array] of folder names with '/'
|
43
56
|
# in end and filenames with fullpath (started ad prefix)
|
@@ -93,11 +106,12 @@ module OnlyofficeS3Wrapper
|
|
93
106
|
# Upload file
|
94
107
|
# @param file_path [String] file to upload
|
95
108
|
# @param upload_folder [String] path to upload
|
109
|
+
# @param content_type [String] content type of file to upload
|
96
110
|
# @return [nil]
|
97
|
-
def upload_file(file_path, upload_folder)
|
111
|
+
def upload_file(file_path, upload_folder, content_type = DEFAULT_CONTENT_TYPE)
|
98
112
|
path = bucket_file_path(File.basename(file_path),
|
99
113
|
upload_folder)
|
100
|
-
@bucket.object(path).upload_file(file_path)
|
114
|
+
@bucket.object(path).upload_file(file_path, content_type: content_type)
|
101
115
|
end
|
102
116
|
|
103
117
|
# Make file public
|
@@ -119,9 +133,12 @@ module OnlyofficeS3Wrapper
|
|
119
133
|
# Upload file/folder and make public
|
120
134
|
# @param file_path [String] file to upload
|
121
135
|
# @param upload_folder [True, False] is this a folder
|
136
|
+
# @param content_type [String] content type of file to upload
|
122
137
|
# @return [String] public url
|
123
|
-
def upload_file_and_make_public(file_path,
|
124
|
-
|
138
|
+
def upload_file_and_make_public(file_path,
|
139
|
+
upload_folder = nil,
|
140
|
+
content_type = DEFAULT_CONTENT_TYPE)
|
141
|
+
upload_file(file_path, upload_folder, content_type)
|
125
142
|
make_public(bucket_file_path(File.basename(file_path), upload_folder))
|
126
143
|
@bucket.object(bucket_file_path(File.basename(file_path),
|
127
144
|
upload_folder)).public_url
|
@@ -142,8 +159,8 @@ module OnlyofficeS3Wrapper
|
|
142
159
|
@access_key_id = File.read("#{key_location}/key").strip
|
143
160
|
@secret_access_key = File.read("#{key_location}/private_key").strip
|
144
161
|
rescue Errno::ENOENT
|
145
|
-
raise Errno::ENOENT, "No key or private key found in #{key_location} "\
|
146
|
-
"Please create files #{key_location}/key "\
|
162
|
+
raise Errno::ENOENT, "No key or private key found in #{key_location} " \
|
163
|
+
"Please create files #{key_location}/key " \
|
147
164
|
"and #{key_location}/private_key"
|
148
165
|
end
|
149
166
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: onlyoffice_s3_wrapper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ONLYOFFICE
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2022-08-05 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: aws-sdk-s3
|
@@ -30,16 +30,16 @@ dependencies:
|
|
30
30
|
name: onlyoffice_file_helper
|
31
31
|
requirement: !ruby/object:Gem::Requirement
|
32
32
|
requirements:
|
33
|
-
- - "
|
33
|
+
- - "<"
|
34
34
|
- !ruby/object:Gem::Version
|
35
|
-
version: '
|
35
|
+
version: '2'
|
36
36
|
type: :runtime
|
37
37
|
prerelease: false
|
38
38
|
version_requirements: !ruby/object:Gem::Requirement
|
39
39
|
requirements:
|
40
|
-
- - "
|
40
|
+
- - "<"
|
41
41
|
- !ruby/object:Gem::Version
|
42
|
-
version: '
|
42
|
+
version: '2'
|
43
43
|
- !ruby/object:Gem::Dependency
|
44
44
|
name: overcommit
|
45
45
|
requirement: !ruby/object:Gem::Requirement
|
@@ -193,6 +193,7 @@ metadata:
|
|
193
193
|
documentation_uri: https://www.rubydoc.info/gems/onlyoffice_s3_wrapper
|
194
194
|
homepage_uri: https://github.com/ONLYOFFICE-QA/onlyoffice_s3_wrapper
|
195
195
|
source_code_uri: https://github.com/ONLYOFFICE-QA/onlyoffice_s3_wrapper
|
196
|
+
rubygems_mfa_required: 'true'
|
196
197
|
post_install_message:
|
197
198
|
rdoc_options: []
|
198
199
|
require_paths:
|
@@ -201,14 +202,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
201
202
|
requirements:
|
202
203
|
- - ">="
|
203
204
|
- !ruby/object:Gem::Version
|
204
|
-
version: '2.
|
205
|
+
version: '2.7'
|
205
206
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
206
207
|
requirements:
|
207
208
|
- - ">="
|
208
209
|
- !ruby/object:Gem::Version
|
209
210
|
version: '0'
|
210
211
|
requirements: []
|
211
|
-
rubygems_version: 3.
|
212
|
+
rubygems_version: 3.3.19
|
212
213
|
signing_key:
|
213
214
|
specification_version: 4
|
214
215
|
summary: ONLYOFFICE Helper Gem for S3
|