Module: Cloudpt::API::Client::Files
- Included in:
- Cloudpt::API::Client
- Defined in:
- lib/cloudpt-api/client/files.rb
Instance Method Summary collapse
- #copy_from_copy_ref(copy_ref, to, options = {}) ⇒ Object
- #download(path, options = {}) ⇒ Object
- #upload(path, data, options = {}) ⇒ Object
Instance Method Details
#copy_from_copy_ref(copy_ref, to, options = {}) ⇒ Object
35 36 37 38 39 40 |
# File 'lib/cloudpt-api/client/files.rb', line 35 def copy_from_copy_ref(copy_ref, to, = {}) raw.copy({ :from_copy_ref => copy_ref, :to_path => to }.merge()) end |
#download(path, options = {}) ⇒ Object
8 9 10 11 12 13 |
# File 'lib/cloudpt-api/client/files.rb', line 8 def download(path, = {}) root = .delete(:root) || Cloudpt::API::Config.mode path = Cloudpt::API::Util.escape(path) url = ["", "Files", root, path].compact.join('/') connection.get_raw(:content, url) end |
#upload(path, data, options = {}) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/cloudpt-api/client/files.rb', line 15 def upload(path, data, = {}) root = .delete(:root) || Cloudpt::API::Config.mode method = .delete(:method) query = Cloudpt::API::Util.query() path = Cloudpt::API::Util.escape(path) url = ["", "Files", root, path].compact.join('/') if method == :post response = connection.post(:content, "#{url}?#{query}", data, { 'Content-Type' => "application/octet-stream", "Content-Length" => data.length.to_s }) else response = connection.put(:content, "#{url}?#{query}", data, { 'Content-Type' => "application/octet-stream", "Content-Length" => data.length.to_s }) end Cloudpt::API::File.init(response, self) end |