Returns an escaped object url @param [String] path of the url @param [String] key of the object @return [String] escaped file url
# File lib/fog/rackspace/models/storage/files.rb, line 171 def self.file_url(path, key) return nil unless path "#{path}/#{Fog::Rackspace.escape(key, '/')}" end
Returns list of files @return [Fog::Storage::Rackspace::Files] Retrieves a list files. @raise [Fog::Storage::Rackspace::NotFound] - HTTP 404 @raise [Fog::Storage::Rackspace::BadRequest] - HTTP 400 @raise [Fog::Storage::Rackspace::InternalServerError] - HTTP 500 @raise [Fog::Storage::Rackspace::ServiceError] @see docs.rackspace.com/files/api/v1/cf-devguide/content/List_Objects-d1e1284.html
# File lib/fog/rackspace/models/storage/files.rb, line 43 def all(options = {}) requires :directory options = { 'limit' => limit, 'marker' => marker, 'path' => path, 'prefix' => prefix }.merge!(options) merge_attributes(options) parent = directory.collection.get( directory.key, options ) if parent load(parent.files.map {|file| file.attributes}) else nil end end
# File lib/fog/rackspace/models/storage/files.rb, line 72 def each if !block_given? self else subset = dup.all subset.each_file_this_page {|f| yield f} while subset.length == (subset.limit || 10000) subset = subset.all(:marker => subset.last.key) subset.each_file_this_page {|f| yield f} end self end end
Calls block for each file in the directory @yieldparam [Fog::Storage::Rackspace::File] @return [Fog::Storage::Rackspace::Directory] returns itself @raise [Fog::Storage::Rackspace::NotFound] - HTTP 404 @raise [Fog::Storage::Rackspace::BadRequest] - HTTP 400 @raise [Fog::Storage::Rackspace::InternalServerError] - HTTP 500 @raise [Fog::Storage::Rackspace::ServiceError] @note This method retrieves files in pages. Page size is defined by the limit attribute
Retrieves file @param [String] key of file @yield get yields to block after chunk of data has been received (Optional) @yieldparam [String] data @yieldparam [Integer] remaining @yieldparam [Integer] content_length @return [Fog::Storage::Rackspace:File] @raise [Fog::Storage::Rackspace::NotFound] - HTTP 404 @raise [Fog::Storage::Rackspace::BadRequest] - HTTP 400 @raise [Fog::Storage::Rackspace::InternalServerError] - HTTP 500 @raise [Fog::Storage::Rackspace::ServiceError] @note If a block is provided, the body attribute will be empty. By default chunk size is 1 MB. This value can be changed by passing the parameter :chunk_size
into the :connection_options hash in the service constructor.
@example Download an image from Cloud Files and save it to file
File.open('download.jpg', 'w') do | f | my_directory.files.get("europe.jpg") do |data, remaing, content_length| f.syswrite data end end
@see docs.rackspace.com/files/api/v1/cf-devguide/content/Retrieve_Object-d1e1856.html
# File lib/fog/rackspace/models/storage/files.rb, line 110 def get(key, &block) requires :directory data = service.get_object(directory.key, key, &block) metadata = Metadata.from_headers(self, data.headers) file_data = data.headers.merge({ :body => data.body, :key => key, :metadata => metadata }) new(file_data) rescue Fog::Storage::Rackspace::NotFound nil end
Returns the public_url for the given object key @param key of the object @return [String] url for object @raise [Fog::Storage::Rackspace::NotFound] - HTTP 404 @raise [Fog::Storage::Rackspace::BadRequest] - HTTP 400 @raise [Fog::Storage::Rackspace::InternalServerError] - HTTP 500 @raise [Fog::Storage::Rackspace::ServiceError] @see Directory#public_url
# File lib/fog/rackspace/models/storage/files.rb, line 133 def get_url(key) requires :directory if self.directory.public_url Files::file_url directory.public_url, key end end
View directory detail without loading file contents @param key of the object @param options Required for compatibility with other Fog providers. Not Used. @return [Fog::Storage::Rackspace::File] @raise [Fog::Storage::Rackspace::NotFound] - HTTP 404 @raise [Fog::Storage::Rackspace::BadRequest] - HTTP 400 @raise [Fog::Storage::Rackspace::InternalServerError] - HTTP 500 @raise [Fog::Storage::Rackspace::ServiceError]
# File lib/fog/rackspace/models/storage/files.rb, line 148 def head(key, options = {}) requires :directory data = service.head_object(directory.key, key) file_data = data.headers.merge({ :key => key }) new(file_data) rescue Fog::Storage::Rackspace::NotFound nil end
Create a new file object @param [Hash] attributes of object @return [Fog::Storage::Rackspace::File]
# File lib/fog/rackspace/models/storage/files.rb, line 162 def new(attributes = {}) requires :directory super({ :directory => directory }.merge!(attributes)) end
Generated with the Darkfish Rdoc Generator 2.