Ruby gem for file managment and sharing in owncloud
Add this line to your application's Gemfile:
gem "ocman", :git => 'git@github.com:tt-laboratories/ocman.git'
Initialize Ocman with your access credentials somewhere during startup. In a rails application that may be an initializer like .../initializers/ocman.rb
.
Ocman.configure do |config|
# Required
config.base_url = 'https://example.org'
config.user_name = ''
config.password = ''
# Optional
config.dav_base_uri = '/remote.php/webdav/' # Optional - URI of the owncloud installation. Defaults to '/remote.php/webdav/'
end
Ocman.share('path/to/folder', 'user_name')
# => #<Hashie::Mash data=nil meta=#<Hashie::Mash message=nil status='ok' statuscode='100'>>
# Share with read-only permissions (default is 'all')
Ocman.share('path/to/folder', 'user_name', Ocman::Permission.read)
# => #<Hashie::Mash data=nil meta=#<Hashie::Mash message=nil status='ok' statuscode='100'>>
# Share with specific set of permissions
Ocman.share('path/to/folder', 'user_name', Ocman::Permission.new([:read, :create, :update]))
# => #<Hashie::Mash data=nil meta=#<Hashie::Mash message=nil status='ok' statuscode='100'>>
Valid permissions are:
read
create
update
delete
share
all
Ocman.delete_share('path/to/folder', 'user_name')
# #<Hashie::Mash data=nil meta=#<Hashie::Mash message=nil status='ok' statuscode='100'>>
Ocman.list('path/to/folder', options={})
# [#<Hashie::Mash path="Documents" size=0 type="directory">, #<Hashie::Mash path="Test.zip" size=127 type="file">]
- recursive - If true the folder contents will be listed recursively
Ocman.create_folder('path/to/folder')
# => ""
Ocman.put('local/file/path', 'remote/path/to/folder', <options>)
# => nil
Available options:
- filename: filename of the file stored in owncloud (defaults to basename of the file)
Ocman.delete('path/to/file')
# => nil
Ocman.move('source_path/of/file', 'destination_path')
# => ""
Web: https://www.toptranslation.com, https://developer.toptranslation.com
Github: https://www.github.com/tt-laboratories
Twitter: @tt_developers, @toptranslation
Mail: tech@toptranslation.com