Class: Baidupan::FsCmd
- Inherits:
-
Base
- Object
- Base
- Baidupan::FsCmd
show all
- Defined in:
- lib/baidupan/fs_cmd.rb
Instance Attribute Summary
Attributes inherited from Base
#body
Class Method Summary
collapse
Methods inherited from Base
common_params, get, #initialize, post, #run!
Constructor Details
This class inherits a constructor from Baidupan::Base
Class Method Details
.download(rpath, lpath, opts = {}) ⇒ Object
24
25
26
27
|
# File 'lib/baidupan/fs_cmd.rb', line 24
def download(rpath, lpath, opts={})
params = common_params(:download, path: "#{Config.app_root}/#{rpath}")
get(Config.file_path, params, opts.merge(followlocation: true))
end
|
.list(rpath, **opts) ⇒ Object
9
10
11
12
|
# File 'lib/baidupan/fs_cmd.rb', line 9
def list(rpath, **opts)
opts.merge!(common_params(:list, path: "#{Config.app_root}/#{rpath}"))
get(Config.file_path, opts)
end
|
.upload(lpath, rpath, opts = {}) ⇒ Object
14
15
16
17
18
19
20
21
22
|
# File 'lib/baidupan/fs_cmd.rb', line 14
def upload(lpath, rpath, opts={})
params = common_params(:upload, path: "#{Config.join_path(rpath, File.basename(lpath))}").merge(ondup: :newcopy)
params[:ondup] = opts.delete(:ondup) if opts[:ondup]
body = {:file => File.open(lpath)}
opts[:noprogress] ||= true
post(Config.file_path, params, body, opts)
end
|