canistor 0.3.1 → 0.3.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/canistor/storage/upload.rb +48 -0
- data/lib/canistor/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2621d73e017b7bbfb296384b7bceb87699d7f71942fa9b85c346d824103f8fc0
|
4
|
+
data.tar.gz: ff98d15d36834943e177a66c4db1c7fee64f96b4cb7398ad4f4c4a179bbfc2c9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1b92e5cbae6bb7d863b3e437df73cd0a23fda1ce3b6533a00499f26ad4eef07c2bd305d263ff68930efc5ab77aeb763c91ba561c0a8dc8aadd608488779e7bf7
|
7
|
+
data.tar.gz: 3460dd2aad6248bddd71cd1cd8595da3b80a871a5568edd47b8455307e552e9e2b3228e5cb4cd45f8e4d28b41b07c68519f155704dd7748463d670101dca4d24
|
@@ -0,0 +1,48 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Canistor
|
4
|
+
module Storage
|
5
|
+
class Upload
|
6
|
+
attr_accessor :id
|
7
|
+
attr_accessor :region
|
8
|
+
attr_accessor :bucket
|
9
|
+
attr_accessor :key
|
10
|
+
|
11
|
+
def initialize(**attributes)
|
12
|
+
@id = SecureRandom.hex(64)
|
13
|
+
attributes.each do |name, value|
|
14
|
+
send("#{name}=", value)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def get(context, subject)
|
19
|
+
show_upload(context)
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
def show_upload(context)
|
25
|
+
context.http_response.signal_headers(
|
26
|
+
200,
|
27
|
+
'date' => Time.now.httpdate,
|
28
|
+
'x-amz-request-id' => SecureRandom.hex(8).upcase
|
29
|
+
)
|
30
|
+
unless context.http_request.http_method == 'HEAD'
|
31
|
+
context.http_response.signal_data(to_xml(context))
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def to_xml(context)
|
36
|
+
Nokogiri::XML::Builder.new do |xml|
|
37
|
+
xml.InitiateMultipartUploadResult(
|
38
|
+
xmlns: 'http://s3.amazonaws.com/doc/2006-03-01/'
|
39
|
+
) do
|
40
|
+
xml.Bucket bucket
|
41
|
+
xml.Key key
|
42
|
+
xml.UploadId id
|
43
|
+
end
|
44
|
+
end.to_xml
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
data/lib/canistor/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: canistor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Manfred Stienstra
|
@@ -99,6 +99,7 @@ files:
|
|
99
99
|
- lib/canistor/storage.rb
|
100
100
|
- lib/canistor/storage/bucket.rb
|
101
101
|
- lib/canistor/storage/object.rb
|
102
|
+
- lib/canistor/storage/upload.rb
|
102
103
|
- lib/canistor/subject.rb
|
103
104
|
- lib/canistor/version.rb
|
104
105
|
homepage: https://erm.im/canistor
|