Thanks to visit codestin.com
Credit goes to github.com

Skip to content

tomash/pcloud

 
 

Repository files navigation

Gem for Pcloud cloud storage

This Gem provides a Ruby interface to Pcloud.com.

Build Status Gem Downloads Gem Version

Want to contribute? Doc Link

Installation and Configuration

Supported Ruby versions: 2.3+

Add pcloud to your Gemfile, and then run bundle install

gem 'pcloud'

or install via gem

gem install pcloud
Rails

to generate Rails initializer file

rails generate pcloud

or add it manually into following path

config/initializers/pcloud.rb

Instantiating a client

require 'pcloud'

pcloud = Pcloud::Client.new(
  username: 'email',
  password: 'password',
).authenticate

pcloud.get("listfolder", folderid: 0)

Global configuration

The library can also be configured globally on the Pcloud class.

Pcloud.username = 'email'
Pcloud.password = 'password'
Pcloud.authenticate

Pcloud.get("listfolder", folderid: 0)

Logging

By default errors are logged in STDOUT level, also Rails.logger available.

Pcloud.logger = Rails.logger

Working with methods

Available methods:

  • Get
  • Post
  • File handling
addition!

Some apis need to be raw format, just add raw in params. params: {fileid: ..987, raw: true} For example gettextfile https://docs.pcloud.com/methods/streaming/gettextfile.html

Get method

Pcloud.get("getip")
Pcloud.get("getdigest")

# with params
params = {folderid: 0}
Pcloud.get("listfolder", params)

Post method

payload = {}
params = {folderid: 0, name: "new folder name"}
Pcloud.post("createfolder", payload, params)
# optional params: filename, destination
# destination by default current_path
Pcloud.file.download({fileid: 987532135})

Pcloud.file.download(
  fileid: 987532135,                   #required
  destination: "#{Dir.pwd}/Downloads", #optional
  filename: "hehe.txt"                 #optional
)
# optional params: filename, destination
# destination by default current_path
Pcloud.file.download_folder({folderid: 123456789})
params = {
  folderid: 0,  #required
  nopartial: 1,
}
# multiple uploads
file1 = File.open("./Rakefile")
file2 = File.open("./README.md")
file3 = File.open("./Gemfile")
payload = { files: [file1,file2,file3] }

Pcloud.file.upload(params, payload)

License

The gem is available as open source under the terms of the MIT License.

About

pCloud's Ruby SDK

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Ruby 100.0%