Module: DocumentFolder

Defined in:
lib/zm/client/folder/mod_document_folder.rb

Constant Summary collapse

UUID_REGEX =
%r{[0-9a-fA-F]{8}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{12}:[0-9a-fA-F]{8}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{12}}

Instance Method Summary collapse

Instance Method Details

#upload(file_path) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/zm/client/folder/mod_document_folder.rb', line 4

def upload(file_path)
  uploader = Zm::Client::Upload.new(@parent, Zm::Client::RestAccountConnector.new)
  str = uploader.upload_attachment(file_path)

  uuid = str.scan(UUID_REGEX).first

  raise Zm::Client::RestError, "failed to extract uuid" if uuid.nil?

  upload_options = { upload: { id: uuid } }
  rep = @parent.sacc.save_document(@parent.token, id, upload_options)

  Zm::Client::Document.new(@parent, rep[:Body][:SaveDocumentResponse][:doc].first)
end