Class: Saaspose::Storage

Inherits:
Object
  • Object
show all
Defined in:
lib/saaspose/storage.rb

Defined Under Namespace

Classes: RemoteFile

Class Method Summary collapse

Class Method Details

.files(remote_folder_path = "") ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
# File 'lib/saaspose/storage.rb', line 15

def files(remote_folder_path="")
  uri = "storage/folder"
  uri << "/#{remote_folder_path}" unless remote_folder_path.empty?
  result = Utils.call_and_parse(uri)

  result["Files"].map do |entry|
    seconds_since_epoch = entry["ModifiedDate"].scan(/[0-9]+/)[0].to_i
    date = Time.at((seconds_since_epoch-(21600000 + 18000000))/1000)
    RemoteFile.new(entry["Name"], entry["IsFolder"], date, entry["Size"])
  end
end

.upload(local_file_path, remote_folder_path) ⇒ Object



8
9
10
11
12
13
# File 'lib/saaspose/storage.rb', line 8

def upload(local_file_path, remote_folder_path)
  file_name = File.basename(local_file_path)
  url_file = "storage/file/#{remote_folder_path.empty? ? "" : "/#{remote_folder_path}" }#{file_name}"
  signed_url = Utils.sign(url_file)
  RestClient.put(signed_url, File.new(local_file_path, 'rb'), :accept => 'application/json')
end