class Matterhorn::Endpoint::Staticfiles

Matterhorn::Endpoint::Staticfiles ===

Public Instance Methods

delete(uuid) click to toggle source

Remove the static file.

# 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) click to toggle source

Persists a recently uploaded file to the permanent storage.

# 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) click to toggle source

Uploads a file into the static file folder on Mattherhorn. Return the uuid of this uploaded resources.

# 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