Sha256: f8b49dca82843bb342db04ef00afb0389704cf4af054edafb4e7d9261d557916

Contents?: true

Size: 611 Bytes

Versions: 2

Compression:

Stored size: 611 Bytes

Contents

#
# wrapper of DropboxApi
#
module DCP
	class Dropbox
		def initialize(token)
			@client = DropboxApi::Client.new(token)
		end

		def open(path, opts)
			if opts =~ /w/ # write
				client = @client
				info = DropboxApi::Metadata::CommitInfo.new('path'=>path, 'mode'=>:add)
				cursor = client.upload_session_start('')
				cursor.define_singleton_method(:write) do |data|
					client.upload_session_append_v2(cursor, data)
				end
				yield cursor
				client.upload_session_finish(cursor, info)
			else # read (default)
				raise StandardError.new('read from dropbox does not implement.')
			end
		end
	end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
dcp-0.1.1 lib/dcp/dropbox.rb
dcp-0.1.0 lib/dcp/dropbox.rb