Class: Occson::Uploader

Inherits:
Object
  • Object
show all
Defined in:
lib/occson/uploader.rb

Overview

Encrypts and uploads the document to Occson.

Instance Method Summary collapse

Constructor Details

#initialize(uri, content, access_token, passphrase, force: false) ⇒ Uploader

Constructs an Uploader instance from a given URI, content, access token and passphrase.

Examples:

uri = 'occson://path/to/file.yml'
content = 'my very secret message'
access_token = 'f30b5450421362c9ca0b'
passphrase = 'my document passphrase'

Occson::Uploader.new(uri, access_token, passphrase)


21
22
23
24
25
26
27
# File 'lib/occson/uploader.rb', line 21

def initialize(uri, content, access_token, passphrase, force: false)
  @uri = uri
  @content = content
  @access_token = access_token
  @passphrase = passphrase
  @force = force.to_s
end

Instance Method Details

#callBoolean

Performs the actual upload to server.



32
33
34
35
# File 'lib/occson/uploader.rb', line 32

def call
  request.body = { encrypted_content: encrypted_content, force: @force }.to_json
  %w[200 201].include?(http.request(request).code)
end