Class: Bunny::Edge::Upload
- Inherits:
-
Object
- Object
- OpenStruct
- Object
- Bunny::Edge::Upload
show all
- Defined in:
- lib/bunny/edge/models/upload.rb
Class Method Summary
collapse
Methods inherited from Object
#camel_to_snake, #initialize, #to_ostruct
Constructor Details
This class inherits a constructor from Bunny::Object
Class Method Details
.create(zone: Bunny.config.edge_name, path:, name:, file:) ⇒ Object
10
11
12
13
14
15
16
17
|
# File 'lib/bunny/edge/models/upload.rb', line 10
def create(zone: Bunny.config.edge_name, path:, name:, file:)
= {
"Content-Type" => Marcel::MimeType.for(file),
"Content-Length" => file.size.to_s
}
response = Edge::Client.put_request([ zone, path, name ].join("/"), body: file, headers: )
response.success?
end
|
.delete(zone:, path:, name:) ⇒ Object
30
31
32
33
|
# File 'lib/bunny/edge/models/upload.rb', line 30
def delete(zone:, path:, name:)
response = Edge::Client.delete_request([ zone, path, name ].join("/"))
response.success?
end
|
.download(zone: Bunny.config.edge_name, path:, name:) ⇒ Object
19
20
21
22
23
24
25
26
27
28
|
# File 'lib/bunny/edge/models/upload.rb', line 19
def download(zone: Bunny.config.edge_name, path:, name:)
response = Edge::Client.get_request([ zone, path, name ].join("/"))
tempfile = Tempfile.new
tempfile.binmode
tempfile.write(response.body)
tempfile.rewind
tempfile
end
|
.list(zone: Bunny.config.edge_name, path:) ⇒ Object