#= NVX::SDS #== A Ruby SDK for Nirvanix #=== Getting the Library #==== Download with RubyGems # #sudo gem i nvx-sds #==== Download from the svn repository # #svn co svn://rubyforge.org/var/svn/nirvanix/sds/trunk nvx-sds #The latest release and support is always available at Nirvanix Development Site # #=== Getting started #After the gems library is installed you will need to: # #require ‘nvx_sds’ #==== Creating a Session #Most operations using this library will use go through the Session object. The session holds authentication and persistent connection information for the Nirvanix account. # #Creating a session can be done using: # #session = Session.new(“APP-KEY”, “USERNAME”, “APP NAME”, “PASSWORD”) # #To get an account go to nmp.nirvanix.com/ and sign up. This will generate a new account and application key that you can use the pass to the session initialize method. # #When you are finished with a session always be sure to log that session out to invalidate the active session token. # #session.Logout # #==== Uploading a file #To upload a file you will need to create a session and an HttpUpload object. The call takes a local file and streams it to the remote server. Below is an example of an upload: # #session = Session.new(“APP-KEY”, “USERNAME”, “APP NAME”, “PASSWORD”) # #remote_file = “TestUpload.txt” # #remote_path = “/” # #overwrite = true # ##Get a file in the current directory # #local_file = File.expand_path(File.join(File.dirname(__FILE__), ‘.’)) + remote_file # #HttpUpload.UploadFile(remote_path, remote_file, local_file, overwrite, session.account_login) # #==== Downloading a file #To download a file you will need to create a session and a HttpDownload object. The call creates a link to a remote Nirvanix file and downloads it to a local file. Below is an example of a download: # #session = Session.new(“APP-KEY”, “USERNAME”, “APP NAME”, “PASSWORD”) # #remote_file = “/TestUpload.txt” # ##Get a file in the current directory # #local_file = File.expand_path(File.join(File.dirname(__FILE__), ‘.’)) + remote_file # #HttpDownload.DownloadFile(remote_path, local_file, session.account_login) # #==== General File operations #There are many different file operations that are available once a file has been uploaded through the API. To get to these operations you can retrieve the root folder. The example below shows this and prints out each folder name. # #session = Session.new(“APP-KEY”, “USERNAME”, “APP NAME”, “PASSWORD”) # #root_folder = session.GetRootFolder(1, 500, 0, true) # #root_folder.folders.each do |folder| # # print folder.name # #end # #The parameters are: # #* CurrentPage - The current page you are requesting #* NumberPerPage - This is the total number of items files or folders #* FolderSortCode - How the list of items returned should be sorted #* SortDescending - If the list of items should be listed in descending order #The maximum number of items reutrned in a single page is 500 # #The folder sort codes are: # #* Name #* CreatedDate #* SizeBytes #* FileType # #LoadChildren must be called to handle paging, due to memory concerns we didnt want to return too many items in one request, doing so could cause problems for people using shared servers with memory caps or other limitations. # #After getting a folder object you can copy, move, rename and delete files or folders. You can read more about folder oprations in the Folder RubyDoc entry. # #File operations can be completed in a similar manor using the NVXFile object # #=== Accounting Operations #The session object lets you get or set account information about the account you used to create the session. This is contact information and the username. The session object can also be used to retrieve a MasterAccount object that will give you the ability to create and delete child accounts, setting and getting account notes and impersonation of children under that master account. # #The master account has a unique set of children and file system per application key but only one set of account contact information. This means each application key is a unique space under the master account. You can read more about this relationship in the official Nirvanix API Documentation. # #As a master account you will not need the password of the child account only the username you wish to impersonate. #=== Transcoding # #There are two transcoding namespaces Audio and Video. The transcode methods let you convert files from one format into another. in the video namespace there is also the ability to extract frames, this is useful for pulling out a certain number of frames from a video or generating thumbnails or preview images. # #===Searching # #You can search in three primary ways, file system, Metadata and Tags. Each search method can be called from the session object and returns an array of SearchItem objects. #