class Baidupan::FsCmd

Public Class Methods

copy(from_rpath, to_rpath) click to toggle source
# File lib/baidupan/fs_cmd.rb, line 50
def copy(from_rpath, to_rpath)
  params = common_params(:copy, 
                         from: "#{Config.join_path(from_rpath)}",
                         to: "#{Config.join_path(to_rpath)}")
  post(Config.file_path, params)
end
delete(rpath) click to toggle source
# File lib/baidupan/fs_cmd.rb, line 57
def delete(rpath)
  params = common_params(:delete, path: "#{Config.join_path(rpath)}")
  post(Config.file_path, params)
end
download(rpath, lpath, opts={}) click to toggle source
# File lib/baidupan/fs_cmd.rb, line 24
def download(rpath, lpath, opts={})
  params = common_params(:download, path: "#{Config.join_path(rpath)}")
              get(Config.file_path, params, opts.merge(followlocation: true))
end
list(rpath, opts={}) click to toggle source
# 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
mkdir(rpath) click to toggle source
# File lib/baidupan/fs_cmd.rb, line 39
def mkdir(rpath)
  post(Config.file_path, common_params(:mkdir, path: "#{Config.join_path(rpath)}"))
end
move(from_rpath, to_rpath) click to toggle source
# File lib/baidupan/fs_cmd.rb, line 43
def move(from_rpath, to_rpath)
  params = common_params(:move, 
                         from: "#{Config.join_path(from_rpath)}",
                         to: "#{Config.join_path(to_rpath)}")
  post(Config.file_path, params)
end
quota() click to toggle source
# File lib/baidupan/fs_cmd.rb, line 62
def quota
  params = common_params(:info)
  get(Config.other_api_path(:quota), params)
end
thumbnail(rpath, opts={}) click to toggle source
# File lib/baidupan/fs_cmd.rb, line 34
def thumbnail(rpath, opts={})
  params = common_params(:generate, path: "#{Config.join_path(rpath)}").merge(opts)
  "#{Config.thumbnail}?" + params.to_query_str
end
upload(lpath, rpath, opts={}) click to toggle source
# 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
url(rpath) click to toggle source
# File lib/baidupan/fs_cmd.rb, line 29
def url(rpath)
  params = common_params(:download, path: "#{Config.join_path(rpath)}")
  "#{Config.file_path}?#{params.to_query_str}"
end