Class: Matterhorn::Endpoint::Staticfiles
- Inherits:
-
Matterhorn::Endpoint
- Object
- Matterhorn::Endpoint
- Matterhorn::Endpoint::Staticfiles
- Defined in:
- lib/matterhorn/endpoint/staticfiles.rb
Overview
Matterhorn::Endpoint::Staticfiles ===
Instance Attribute Summary
Attributes inherited from Matterhorn::Endpoint
#response_body, #response_code
Instance Method Summary collapse
-
#delete(uuid) ⇒ Object
Remove the static file.
-
#persist(uuid) ⇒ Object
Persists a recently uploaded file to the permanent storage.
-
#upload(file) ⇒ Object
Uploads a file into the static file folder on Mattherhorn.
Methods inherited from Matterhorn::Endpoint
#close, create, #error_code, #error_msg, #error_occurred?, #initialize, open
Constructor Details
This class inherits a constructor from Matterhorn::Endpoint
Instance Method Details
#delete(uuid) ⇒ Object
Remove the static file.
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/matterhorn/endpoint/staticfiles.rb', line 66 def delete(uuid) deleted = false begin split_response http_endpoint_client.delete( "staticfiles/#{uuid}" ) deleted = true rescue => ex exception_handler('delete', ex, { 400 => "No file by the given UUID #{uuid} found." } ) end deleted end |
#persist(uuid) ⇒ Object
Persists a recently uploaded file to the permanent storage.
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/matterhorn/endpoint/staticfiles.rb', line 36 def persist(uuid) persisted = false begin split_response http_endpoint_client.post( "staticfiles/#{uuid}/persist", {} ) persisted = true rescue => ex exception_handler('persist', ex, { 400 => "No file by the given UUID #{uuid} found." } ) end persisted end |
#upload(file) ⇒ Object
Uploads a file into the static file folder on Mattherhorn. Return the uuid of this uploaded resources.
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/matterhorn/endpoint/staticfiles.rb', line 16 def upload(file) uuid = nil begin split_response http_endpoint_client.post( "staticfiles", { 'BODY' => file } ) uuid = response_body rescue => ex exception_handler('upload', ex, { 400 => "No filename or file to upload found. Or the uploaded size is too big" } ) end uuid end |