Gem for Pcloud cloud storage

This Gem provides a Ruby interface to Pcloud.com.

Build Status Gem Downloads Gem Version

Installation and Configuration

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',
)

Global configuration

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

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

Working with methods

Currently, only available custom Get method.

File Upload and Download methods are coming soon.

Get methods

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

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

Post methods

# if any of pcloud endpoints requires payload on POST request, please create an issue.

# with params
Pcloud.post("createfolder", folderid: 0, name: "new folder name")

Files

Download File
#obtain filelink from: https://docs.pcloud.com/methods/streaming/getfilelink.html

Pcloud.file.download(
  url: filelink,                           #required
  destination: "#{Dir.pwd}/Downloads",     #required
  filename: "hehe.txt"                     #optional
)
Upload File
# still in BETA! -  
# only supports single file upload

file = File.open("/Users/7urkm3n/Downloads/anything.file")
params = {
  folderid: 0,                #required
  filename: "anything.txt"    #required
}
payload = {file: file}
Pcloud.file.upload(params, payload)

Supported Ruby versions

2.2+