Sha256: fab50e9e32bf25c3725afca79f4ffa463b414a6bd214d6482de7c15d96a899ab

Contents?: true

Size: 713 Bytes

Versions: 2

Compression:

Stored size: 713 Bytes

Contents

require 'rmega/utils'
require 'rmega/nodes/uploadable'
require 'rmega/crypto/crypto'

module Rmega
  module Nodes
    module Expandable
      include Uploadable

      def create_folder(name)
        key = Crypto.random_key
        encrypted_attributes = Utils.a32_to_base64 Crypto.encrypt_attributes(key[0..3], {n: name.strip})
        encrypted_key = Utils.a32_to_base64 Crypto.encrypt_key(session.master_key, key)
        n = [{h: 'xxxxxxxx', t: 1, a: encrypted_attributes, k: encrypted_key}]
        data = session.request a: 'p', t: handle, n: n
        Folder.new(session, data['f'][0])
      end

      def upload_url(filesize)
        session.request(a: 'u', s: filesize)['p']
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rmega-0.1.7 lib/rmega/nodes/expandable.rb
rmega-0.1.6 lib/rmega/nodes/expandable.rb