class GroupDocs::Storage::Folder
Attributes
@attr [Symbol] access
@attr [Time] created_on
@attr [Integer] file_count
@attr [Integer] folder_count
@attr [Integer] id
@attr [Time] modified_on
@attr [String] name
@attr [String] path
@attr [Integer] size
@attr [Integer] type
@attr [String] url
@attr [Integer] version
Public Class Methods
Creates folder on server.
@param [String] path Path of folder to create starting with “/” @param [Hash] access Access credentials @option access [String] :client_id @option access [String] :private_key @return [GroupDocs::Storage::Folder] Created folder
# File lib/groupdocs/storage/folder.rb, line 17 def self.create!(path, access = {}) path = prepare_path(path) json = Api::Request.new do |request| request[:access] = access request[:method] = :POST request[:path] = "/storage/{{client_id}}/paths/#{path}" end.execute! Storage::Folder.new(json) end
Returns a list of all directories and files in the path.
@param [String] path Path of directory to list starting from root (‘/’) @param [Hash] options Hash of options @option options [Integer] :page Page to start with @option options [Integer] :count How many items to list @option options [String] :order_by Field name to sort by @option options [Boolean] :order_asc Set to true to return in ascending order @param [Hash] access Access credentials @option access [String] :client_id @option access [String] :private_key @return [Array<GroupDocs::Storage::Folder, GroupDocs::Storage::File
>]
# File lib/groupdocs/storage/folder.rb, line 43 def self.list!(path = '', options = {}, access = {}) path = prepare_path(path) new(:path => path).list!(options, access) end
Public Instance Methods
Copies folder contents to given path.
@param [String] destination_path Destination to copy contents to @param [Hash] access Access credentials @option access [String] :client_id @option access [String] :private_key @return [String] Copied to folder path
# File lib/groupdocs/storage/folder.rb, line 175 def copy!(destination, access = {}) src_path = prepare_path(path) dst_path = prepare_path("#{destination}/#{name}") Api::Request.new do |request| request[:access] = access request[:method] = :PUT request[:headers] = { :'Groupdocs-Copy' => src_path } request[:path] = "/storage/{{client_id}}/folders/#{dst_path}" end.execute! dst_path end
Creates folder on server.
Note that it doesn’t update self and instead returns new instance.
@example
folder = GroupDocs::Storage::Folder.new(name: 'Folder') folder = folder.create!
@param [Hash] access Access credentials @option access [String] :client_id @option access [String] :private_key @return [GroupDocs::Storage::Folder] Created folder
# File lib/groupdocs/storage/folder.rb, line 203 def create!(access = {}) self.class.create! prepare_path("#{path}/#{name}"), access end
Deletes folder from server.
@param [Hash] access Access credentials @option access [String] :client_id @option access [String] :private_key
# File lib/groupdocs/storage/folder.rb, line 214 def delete!(access = {}) Api::Request.new do |request| request[:access] = access request[:method] = :DELETE request[:path] = "/storage/{{client_id}}/folders/#{prepare_path("#{path}/#{name}")}" end.execute! end
Returns an array of files and folders.
@param [Hash] options Hash of options @option options [Integer] :page Page to start with @option options [Integer] :count How many items to list @option options [String] :order_by Field name to sort by @option options [Boolean] :order_asc Set to true to return in ascending order @option options [String] :filter Filter by name @option options [Array<Symbol>] :file_types Array of file types to return @option options [Boolean] :extended Set to true to return extended information @param [Hash] access Access credentials @option access [String] :client_id @option access [String] :private_key @return [Array<GroupDocs::Storage::Folder, GroupDocs::Storage::File
>]
# File lib/groupdocs/storage/folder.rb, line 116 def list!(options = {}, access = {}) if options[:order_by] options[:order_by] = options[:order_by].camelize end full_path = prepare_path("#{path}/#{name}") api = Api::Request.new do |request| request[:access] = access request[:method] = :GET request[:path] = "/storage/{{client_id}}/folders/#{full_path}" end api.add_params(options) json = api.execute! folders = json[:folders].map do |folder| folder.merge!(:path => full_path) Storage::Folder.new(folder) end files = json[:files].map do |file| file.merge!(:path => full_path) Storage::File.new(file) end folders + files end
Moves folder contents to given path.
@param [String] destination Destination to move contents to @param [Hash] access Access credentials @option access [String] :client_id @option access [String] :private_key @return [String] Moved to folder path
# File lib/groupdocs/storage/folder.rb, line 152 def move!(destination, access = {}) src_path = prepare_path(path) dst_path = prepare_path("#{destination}/#{name}") Api::Request.new do |request| request[:access] = access request[:method] = :PUT request[:headers] = { :'Groupdocs-Move' => src_path } request[:path] = "/storage/{{client_id}}/folders/#{dst_path}" end.execute! dst_path end