Nirvanix Web Services

Show / Hide Samples: Toggle C# Toggle Java Toggle PHP

API Developer's Guide v2.0 - Code Samples

Release 2.4.8

3/24/2010

Getting Started: Languages and Setup

What languages are supported?

Three primary languages are supported at this time. These languages were chosen due to their popularity among our users. Other languages will be added as popularity rises or specific examples are needed.

  • C#
  • Java - JDK 1.5+
  • PHP - Zend Framework 1.5+

How do I use the sample code provided?

The languages provided all have SDKs we make publicly available for download. These SDKs should be used in each of the specified languages. This will allow you to use the latest client technology and reduce the amount of work you need to do when starting your project. Below each language SDK is specified, please follow the instructions in each individual SDK for setup and installation.

  • Nirvanix C# Flat SDK - http://xxx/
  • Nirvanix Java SDK - http://xxx/
  • Nirvanix PHP SDK in Zend Framework - http://xxx/

back to top

Accounting Namespace

The Accounting Namespace allows users to set and retrieve the limits, contact information, and usage for accounts. These settings control the access to a users files. This component exposes the commands that allow a Master Account to create child accounts, and set and read their limits.

CreateChildAccount

Creates a child account under an application. *Requires master account.

Reference Documentation

C# Example (FlatSDK)

public void callCreateChildAccount() {
	FlatSDK.Session session = new Session("ABCD-555443-APPKEY-DDEE44",
		"USERNAME",
		"PASSWORD");
	FlatSDK.Accounting acct = new FlatSDK.Accounting(session);
    // Create a child account.
	acct.CreateChildAccount("username",
			"password",
			"joe",
			"lname",
			"a",
			"123-123-1234",
			"joe@mail.com",
			EmailFormat.Text,
			"123 Here St.",
			"Unit #12",
			"Good City",
			"CA",
			Countries.UnitedStates,
			"91111");
}
				

Java Example

package com.nirvanix.sdk.session;

class CreateChildAccount {
	public void callCreateChildAccount()  throws NirvanixException,
	                                         SDKException,
	                                         IOException {
		// Get the session
		Session session = new Session("ABCD-555443-APPKEY-DDEE44",
			"USERNAME",
			"PASSWORD",
			"APPNAME");
		MasterAccountSession masterAcct = session.getMasterAccountSession();

 		String userName = "username";
        String password = "password";
        String firstName = "joe";
        String lastName = "lname";
        String middleInitial = "o";
        String phoneNumber = "123-123-1234";
        String emailAddress = "joe@mail.com";
        EmailFormat emailFormat = EmailFormat.Text;
        String addressLine1 = "123 Here St.";
        String addressLine2 = "Unit #12";
        String city = "Good City";
        String state = "CA";
        Country country = Country.UnitedStates;
        String postalCode = "91111";
        
        // create the child
        masterAcct.createChildAccount(userName, password, firstName, lastName, middleInitial, phoneNumber, emailAddress, emailFormat, addressLine1, addressLine2, city, state, country, postalCode);
	}
}
				

PHP Example (Zend SDK)

require_once $INCLUDEPATH . '/Zend/Service/Nirvanix.php'; 

// Get Session token for the user/password under the AppKey
$auth = array('username' => $username,'password' => $password,'appKey' => $appkey);

try{
	// This authenticates the user and retrieves session
	$nirvanix = new Zend_Service_Nirvanix($auth);
	// Get accounting object.
	$acct = $nirvanix->getService('Accounting');
	$createchildParams = array('username' => 'username',
			'password' => 'password',
			'firstname' => 'joe',
			'lastname' => 'lname',
			'middleinitial' => 'o',
			'phoneNumber' => '123-123-1234',
			'emailAddress' => 'joe@mail.com',
			'emailFormat' => 'text',
			'addressLine1' => '123 Here St.',
			'addressLine2' => 'unit #12',
			'city' => 'Good City',
			'state' => 'CA',
			'country' => '1',
			'postalCode' => '91111');
	// Create the child account
	$acct->CreateChildAccount($createchildParams);
}catch (Zend_Service_Nirvanix_Exception $e) {
	$error = true;
}
				
back to top

DeleteChildAccount

Deletes a child account under an application and removes all files under that child account. *Requires master account.

Reference Documentation

C# Example (FlatSDK)

public void callDeleteChildAccount() {
	FlatSDK.Session session = new Session("ABCD-555443-APPKEY-DDEE44",
		"USERNAME",
		"PASSWORD");
	FlatSDK.Accounting acct = new FlatSDK.Accounting(session);
    // Delete a child account.
	acct.DeleteChildAccount("userToDelete");
}
				

Java Example

package com.nirvanix.sdk.session;

class DeleteChildAccount {
	public void callDeleteChildAccount()  throws NirvanixException,
	                                         SDKException,
	                                         IOException {
		// Get the session
		Session session = new Session("ABCD-555443-APPKEY-DDEE44",
			"USERNAME",
			"PASSWORD",
			"APPNAME");
		MasterAccountSession masterAcct = session.getMasterAccountSession();

        // Delete the child account
        masterAcct.deleteChildAccount("userToDelete");
	}
}
				

PHP Example (Zend SDK)

require_once $INCLUDEPATH . '/Zend/Service/Nirvanix.php'; 

// Get Session token for the user/password under the AppKey
$auth = array('username' => $username,'password' => $password,'appKey' => $appkey);

try{
	// This authenticates the user and retrieves session
	$nirvanix = new Zend_Service_Nirvanix($auth);
	// Get accounting object.
	$acct = $nirvanix->getService('Accounting');
	// Delete the child account
	$acct->DeleteChildAccount(array('username' => 'userToDelete'));
}catch (Zend_Service_Nirvanix_Exception $e) {
	$error = true;
}
				
back to top

GetAccountUsage

Gets current usage for an account. *Requires master account.

Reference Documentation

C# Example (FlatSDK)

public void callGetAccountUsage() {
	FlatSDK.Session session = new Session("ABCD-555443-APPKEY-DDEE44",
		"USERNAME",
		"PASSWORD");
	FlatSDK.Accounting acct = new FlatSDK.Accounting(session);
    // Get Account usage information.
	AccountFeatureUsage[] usage = acct.GetAccountUsage("userWithUsage");
	foreach (AccountFeatureUsage feature in usage) {
		Console.WriteLine(feature.FeatureName + ": " + feature.TotalUsageAmount.ToString());
	}
}
				

Java Example

package com.nirvanix.sdk.session;

class GetAccountUsage {
	public void callGetAccountUsage()  throws NirvanixException,
	                                         SDKException,
	                                         IOException {
		// Get the session
		Session session = new Session("ABCD-555443-APPKEY-DDEE44",
			"USERNAME",
			"PASSWORD",
			"APPNAME");
		MasterAccountSession masterAcct = session.getMasterAccountSession();

        // impersonate a child account
		masterAcct.impersonateUser("childAcctWithUsage");
        
		// Get child accounts usage.
        AccountFeatureUsage[] result = masterAcct.getAccountUsage();

		// Switch back to master account when finished.
		masterAcct.stopUserImpersonation();
	}
}
				

PHP Example (Zend SDK)

require_once $INCLUDEPATH . '/Zend/Service/Nirvanix.php'; 

// Get Session token for the user/password under the AppKey
$auth = array('username' => $username,'password' => $password,'appKey' => $appkey);

try{
	// This authenticates the user and retrieves session
	$nirvanix = new Zend_Service_Nirvanix($auth);
	// Get accounting object.
	$acct = $nirvanix->getService('Accounting');
	// Get usage for a child account
	$results = $acct->GetAccountUsage(array('username' => 'userWithUsage'));
	print_r($results);
}catch (Zend_Service_Nirvanix_Exception $e) {
	$error = true;
}
				
back to top

GetAccountLimits

Gets current limits for an account, they will only be returned if they are set. *Requires master account.

Reference Documentation

C# Example (FlatSDK)

public void callGetAccountLimits() {
	FlatSDK.Session session = new Session("ABCD-555443-APPKEY-DDEE44",
		"USERNAME",
		"PASSWORD");
	FlatSDK.Accounting acct = new FlatSDK.Accounting(session);
    // Get Account limits.
	AccountLimitData[] limits = acct.GetAccountLimits("userWithLimits");
	foreach (AccountLimitData limit in limits) {
		Console.WriteLine(limit.Type + ": " + limit.Value.ToString());
	}
}
				

Java Example

package com.nirvanix.sdk.session;

class GetAccountLimits {
	public void callGetAccountLimits()  throws NirvanixException,
	                                         SDKException,
	                                         IOException {
		// Get the session
		Session session = new Session("ABCD-555443-APPKEY-DDEE44",
			"USERNAME",
			"PASSWORD",
			"APPNAME");
		MasterAccountSession masterAcct = session.getMasterAccountSession();

        // impersonate a child account
		masterAcct.impersonateUser("childAcctWithLimits");
        
		// Get child accounts limits.
        AccountLimitData[] result = masterAcct.getAccountLimits();

		// Switch back to master account when finished.
		masterAcct.stopUserImpersonation();
	}
}
				

PHP Example (Zend SDK)

require_once $INCLUDEPATH . '/Zend/Service/Nirvanix.php'; 

// Get Session token for the user/password under the AppKey
$auth = array('username' => $username,'password' => $password,'appKey' => $appkey);

try{
	// This authenticates the user and retrieves session
	$nirvanix = new Zend_Service_Nirvanix($auth);
	// Get accounting object.
	$acct = $nirvanix->getService('Accounting');
	// Get limits for a child account
	$results = $acct->GetAccountLimits(array('username' => 'userWithLimits'));
	print_r($results);
}catch (Zend_Service_Nirvanix_Exception $e) {
	$error = true;
}
				
back to top

SetAccountLimits

Sets current limits for an account. *Requires master account.

Reference Documentation

C# Example (FlatSDK)

public void callSetAccountLimits() {
	FlatSDK.Session session = new Session("ABCD-555443-APPKEY-DDEE44",
		"USERNAME",
		"PASSWORD");
	FlatSDK.Accounting acct = new FlatSDK.Accounting(session);
    // Set Account limits.
	IAccountLimitData[] limits = { new AccountLimitData(LimitFeature.StorageAmount, 12345) };

	acct.SetAccountLimits("username", limits);
}
				

Java Example

package com.nirvanix.sdk.session;

class SetAccountLimits {
	public void callSetAccountLimits()  throws NirvanixException,
	                                         SDKException,
	                                         IOException {
		// Get the session
		Session session = new Session("ABCD-555443-APPKEY-DDEE44",
			"USERNAME",
			"PASSWORD",
			"APPNAME");
		MasterAccountSession masterAcct = session.getMasterAccountSession();

        // impersonate a child account
		masterAcct.impersonateUser("childAcctWithLimits");
        
		// Setup limit array.
		AccountLimitData[] limitsToSet = { new AccountLimitData(LimitFeature.StorageAmount, 12345) };
        
		// Set child accounts limits.
        masterAcct.setAccountLimits(limitsToSet);

		// Switch back to master account when finished.
		masterAcct.stopUserImpersonation();
	}
}
				

PHP Example (Zend SDK)

require_once $INCLUDEPATH . '/Zend/Service/Nirvanix.php'; 

// Get Session token for the user/password under the AppKey
$auth = array('username' => $username,'password' => $password,'appKey' => $appkey);

try{
	// This authenticates the user and retrieves session
	$nirvanix = new Zend_Service_Nirvanix($auth);
	// Get accounting object.
	$acct = $nirvanix->getService('Accounting');
	// Set limits for a child account
	$acct->SetAccountLimits(array('username' => 'userWithLimits', 'StorageAmount' => '12345'));
}catch (Zend_Service_Nirvanix_Exception $e) {
	$error = true;
}
				
back to top

GetAccountInfo

Gets information about a single account such as the first, lastname, etc.. *Requires master account.

Reference Documentation

C# Example (FlatSDK)

public void callGetAccountInfo() {
	FlatSDK.Session session = new Session("ABCD-555443-APPKEY-DDEE44",
		"USERNAME",
		"PASSWORD");
	FlatSDK.Accounting acct = new FlatSDK.Accounting(session);
    // Get Account Info.
	AccountInfo acctInfo = acct.GetAccountInfo("acctWithInfo");
	Console.WriteLine("Account Firstname: " + acctInfo.ContactInfo.FirstName); 
}
				

Java Example

package com.nirvanix.sdk.session;

class GetAccountInfo {
	public void callGetAccountInfo()  throws NirvanixException,
	                                         SDKException,
	                                         IOException {
		// Get the session
		Session session = new Session("ABCD-555443-APPKEY-DDEE44",
			"USERNAME",
			"PASSWORD",
			"APPNAME");
		MasterAccountSession masterAcct = session.getMasterAccountSession();

        // impersonate a child account
		masterAcct.impersonateUser("childAcctWithInfo");
        
		// Get the child accounts info.
        AccountInfo acctInfo = masterAcct.getAccountInfo();

		// acctInfo.getContactInfo().getFirstName();

		// Switch back to master account when finished.
		masterAcct.stopUserImpersonation();
	}
}
				

PHP Example (Zend SDK)

require_once $INCLUDEPATH . '/Zend/Service/Nirvanix.php'; 

// Get Session token for the user/password under the AppKey
$auth = array('username' => $username,'password' => $password,'appKey' => $appkey);

try{
	// This authenticates the user and retrieves session
	$nirvanix = new Zend_Service_Nirvanix($auth);
	// Get accounting object.
	$acct = $nirvanix->getService('Accounting');
	// Get Info for a child account
	$acctInfo = $acct->GetAccountInfo(array('username' => 'userWithInfo'));
	print_r($acctInfo);
}catch (Zend_Service_Nirvanix_Exception $e) {
	$error = true;
}
				
back to top

SetAccountInfo

Sets information for a single account such as the first, lastname, etc.. *Requires master account.

Reference Documentation

C# Example (FlatSDK)

public void callSetAccountInfo() {
	FlatSDK.Session session = new Session("ABCD-555443-APPKEY-DDEE44",
		"USERNAME",
		"PASSWORD");
	FlatSDK.Accounting acct = new FlatSDK.Accounting(session);
    // Set Account Info.
	acct.SetAccountInfo("username",
			"joe",
			"newlname",
			"a",
			"123-123-1234",
			"joe@mail.com",
			EmailFormat.Text,
			"123 Here St.",
			"Unit #12",
			"Good City",
			"CA",
			Countries.UnitedStates,
			"91111");
}
				

Java Example

package com.nirvanix.sdk.session;

class SetAccountInfo {
	public void callSetAccountInfo()  throws NirvanixException,
	                                         SDKException,
	                                         IOException {
		// Get the session
		Session session = new Session("ABCD-555443-APPKEY-DDEE44",
			"USERNAME",
			"PASSWORD",
			"APPNAME");
		MasterAccountSession masterAcct = session.getMasterAccountSession();

        // Impersonate a child account
		masterAcct.impersonateUser("childAcctWithInfo");
        
		// Set the child accounts info.
        masterAcct.setAccountInfo("joe",
                "newlname",
                "o",
                "123-123-1234",
                "joe@mail.com",
                EmailFormat.Text,
                "123 Here St.",
                "Unit #12",
                "Good City",
                "CA",
                Country.UnitedState,
                "91111");

		// Switch back to master account when finished.
		masterAcct.stopUserImpersonation();
	}
}
				

PHP Example (Zend SDK)

require_once $INCLUDEPATH . '/Zend/Service/Nirvanix.php'; 

// Get Session token for the user/password under the AppKey
$auth = array('username' => $username,'password' => $password,'appKey' => $appkey);

try{
	// This authenticates the user and retrieves session
	$nirvanix = new Zend_Service_Nirvanix($auth);
	// Get accounting object.
	$acct = $nirvanix->getService('Accounting');
	// Set Info for a child account
	$setacctinfoParams = array('username' => 'username',
			'firstname' => 'joe',
			'lastname' => 'newlname',
			'middleinitial' => 'o',
			'phoneNumber' => '123-123-1234',
			'emailAddress' => 'joe@mail.com',
			'emailFormat' => 'text',
			'addressLine1' => '123 Here St.',
			'addressLine2' => 'unit #12',
			'city' => 'Good City',
			'state' => 'CA',
			'country' => '1',
			'postalCode' => '91111');
	$acct->SetAccountInfo($setacctinfoParams);	
}catch (Zend_Service_Nirvanix_Exception $e) {
	$error = true;
}
				
back to top

GetAccountNotes

Gets account notes for a specific account. *Requires master account.

Reference Documentation

C# Example (FlatSDK)

public void callGetAccountNotes() {
	FlatSDK.Session session = new Session("ABCD-555443-APPKEY-DDEE44",
		"USERNAME",
		"PASSWORD");
	FlatSDK.Accounting acct = new FlatSDK.Accounting(session);
    // Get Account Notes in an XmlDocument.
	XmlDocument xmldoc = acct.GetAccountNotes("userWithNotes");
}
				

Java Example

package com.nirvanix.sdk.session;

class GetAccountNotes {
	public void callGetAccountNotes()  throws NirvanixException,
	                                         SDKException,
	                                         IOException {
		// Get the session
		Session session = new Session("ABCD-555443-APPKEY-DDEE44",
			"USERNAME",
			"PASSWORD",
			"APPNAME");
		MasterAccountSession masterAcct = session.getMasterAccountSession();

        // Impersonate a child account
		masterAcct.impersonateUser("childAcctWithInfo");
        
		// Get the child account notes.
        String notes = masterAcct.getAccountNotes("userWithNotes");

		// Switch back to master account when finished.
		masterAcct.stopUserImpersonation();
	}
}
				

PHP Example (Zend SDK)

require_once $INCLUDEPATH . '/Zend/Service/Nirvanix.php'; 

// Get Session token for the user/password under the AppKey
$auth = array('username' => $username,'password' => $password,'appKey' => $appkey);

try{
	// This authenticates the user and retrieves session
	$nirvanix = new Zend_Service_Nirvanix($auth);
	// Get accounting object.
	$acct = $nirvanix->getService('Accounting');
	// Get Notes for a child account
	$notes = $acct->GetAccountNotes(array('username' => 'userWithNotes'));	
	print_r($notes);
}catch (Zend_Service_Nirvanix_Exception $e) {
	$error = true;
}
				
back to top

SetAccountNotes

Sets account notes for a specific account. *Requires master account.

Reference Documentation

C# Example (FlatSDK)

public void callSetAccountNotes() {
	FlatSDK.Session session = new Session("ABCD-555443-APPKEY-DDEE44",
		"USERNAME",
		"PASSWORD");
	FlatSDK.Accounting acct = new FlatSDK.Accounting(session);
	XmlDocument xmldoc = new XmlDocument("This is a noteThis is a second note");
    // Set Account Notes.
	acct.SetAccountNotes("username", xmldoc);
}
				

Java Example

package com.nirvanix.sdk.session;

class SetAccountNotes {
	public void callSetAccountNotes()  throws NirvanixException,
	                                         SDKException,
	                                         IOException {
		// Get the session
		Session session = new Session("ABCD-555443-APPKEY-DDEE44",
			"USERNAME",
			"PASSWORD",
			"APPNAME");
		MasterAccountSession masterAcct = session.getMasterAccountSession();

		String notes = "This is a noteThis is a second note";
        // Set Account Notes
		masterAcct.setAccountNotes("childWithNotes", notes);
	}
}
				

PHP Example (Zend SDK)

require_once $INCLUDEPATH . '/Zend/Service/Nirvanix.php'; 

// Get Session token for the user/password under the AppKey
$auth = array('username' => $username,'password' => $password,'appKey' => $appkey);

try{
	// This authenticates the user and retrieves session
	$nirvanix = new Zend_Service_Nirvanix($auth);
	// Get accounting object.
	$acct = $nirvanix->getService('Accounting');
	// Set Notes for a child account
	$setacctnotesParams = array('username' => 'userWithNotes',
			'xmlNotes' => 'This is a noteThis is a second note');
	$acct->SetAccountNotes($setacctnotesParams);	
}catch (Zend_Service_Nirvanix_Exception $e) {
	$error = true;
}
				
back to top

GetStorageUsage

Gets the average storage usage for a specific account. *Requires master account.

Reference Documentation

C# Example (FlatSDK)

public void callGetStorageUsage() {
	FlatSDK.Session session = new Session("ABCD-555443-APPKEY-DDEE44",
		"USERNAME",
		"PASSWORD");
	FlatSDK.Accounting acct = new FlatSDK.Accounting(session);
	long storage = acct.GetStorageUsage("userWithStorage");
}
				

Java Example

package com.nirvanix.sdk.session;

class GetStorageUsage {
	public void callGetStorageUsage()  throws NirvanixException,
	                                         SDKException,
	                                         IOException {
		// Get the session
		Session session = new Session("ABCD-555443-APPKEY-DDEE44",
			"USERNAME",
			"PASSWORD",
			"APPNAME");
		MasterAccountSession masterAcct = session.getMasterAccountSession();

        // Set Account Notes
		long storage = masterAcct.getStorageUsage("userWithStorage");
	}
}
				

PHP Example (Zend SDK)

require_once $INCLUDEPATH . '/Zend/Service/Nirvanix.php'; 

// Get Session token for the user/password under the AppKey
$auth = array('username' => $username,'password' => $password,'appKey' => $appkey);

try{
	// This authenticates the user and retrieves session
	$nirvanix = new Zend_Service_Nirvanix($auth);
	// Get accounting object.
	$acct = $nirvanix->getService('Accounting');
	// Get the storage usage for an account.
	$acct->SetAccountNotes(array('username' => 'userWithStorage'));	
}catch (Zend_Service_Nirvanix_Exception $e) {
	$error = true;
}
				
back to top

ListChildAccounts

Returns the child accounts for an application. *Requires master account.

Reference Documentation

C# Example (FlatSDK)

public void callListChildAccounts() {
	FlatSDK.Session session = new Session("ABCD-555443-APPKEY-DDEE44",
		"USERNAME",
		"PASSWORD");
	FlatSDK.Accounting acct = new FlatSDK.Accounting(session);
	String[] children = acct.ListChildAccounts(1, 500);
}
				

Java Example

package com.nirvanix.sdk.session;

class GetStorageUsage {
	public void callGetStorageUsage()  throws NirvanixException,
	                                         SDKException,
	                                         IOException {
		// Get the session
		Session session = new Session("ABCD-555443-APPKEY-DDEE44",
			"USERNAME",
			"PASSWORD",
			"APPNAME");
		MasterAccountSession masterAcct = session.getMasterAccountSession();

        // Set Account Notes
		String[] children = masterAcct.listChildAccounts(1, 500);
	}
}
				

PHP Example (Zend SDK)

require_once $INCLUDEPATH . '/Zend/Service/Nirvanix.php'; 

// Get Session token for the user/password under the AppKey
$auth = array('username' => $username,'password' => $password,'appKey' => $appkey);

try{
	// This authenticates the user and retrieves session
	$nirvanix = new Zend_Service_Nirvanix($auth);
	// Get accounting object.
	$acct = $nirvanix->getService('Accounting');
	// Get the children for this master acct.
	$children = $acct->ListChildAccounts(array('pagenumber' => '1', 'pageSize' => '500'));	
	print_r($children);
}catch (Zend_Service_Nirvanix_Exception $e) {
	$error = true;
}
				
back to top

Audio Namespace

The Audio namespace allows sound format conversion through transcode.

Transcode

Converts an audio file from one format to another creating a new file. The results are returned in a callback.

Reference Documentation

C# Example (FlatSDK)

public void callAudioTranscode() {
	FlatSDK.Session session = new Session("ABCD-555443-APPKEY-DDEE44",
		"USERNAME",
		"PASSWORD");
	FlatSDK.Audio audio = new FlatSDK.Audio(session);
    // Convert an audio file
	IAudioTranscodingOptions[] options = { new AudioTranscodingOptions(AudioTranscodingOptionList.Bitrate, "192000") };
	audio.transcode("/sourceFilePath/sounds.wav",
			options,
			"/destFilePath/newsounds.mp3",
			"AudioTranscodingFormat.MP3,
			"http://www.yoursite.com/callbackhandler");
}
				

Java Example

package com.nirvanix.sdk.session;

class AudioTranscode {
	public void callAudioTranscode()  throws NirvanixException,
	                                         SDKException,
	                                         IOException {
		// Get the session
		Session session = new Session("ABCD-555443-APPKEY-DDEE44",
			"USERNAME",
			"PASSWORD",
			"APPNAME");
		// Get the files in /path/.
		ArrayList files = session.getFolder("/path/", 1, 
		      500, folderSortCode.Name, true).getFiles();
		// Transcode Audio file.
		AudioTranscodingOptions[] options = { new AudioTranscodingOptions(AudioTranscodingOptionList.Bitrate, "192000") };
        TranscodingFormat targetFormat = TranscodingFormat.MP3;
		String callbackURL = "http://www.yoursite.com/callbackhandler";

        files.get(0).transcodeAudio("/destFilePath/newsounds.mp3", options, targetFormat, callbackURL);
	}
}
				

PHP Example (Zend SDK)

require_once $INCLUDEPATH . '/Zend/Service/Nirvanix.php'; 

// Get Session token for the user/password under the AppKey
$auth = array('username' => $username,'password' => $password,'appKey' => $appkey);

try{
	// This authenticates the user and retrieves session
	$nirvanix = new Zend_Service_Nirvanix($auth);
	// Get audio object.
	$audio = $nirvanix->getService('Audio');
	$audioTranscodeParams = array('srcFilePath' => '/sourcepath/sounds.wav",
			'destFilePath' => '/destpath/newsounds.mp3",
			'bitrate' => '192000',
			'callbackURL' => 'http://www.yoursite.com/callbackhandler.php');
	// Audio Transcode file
	$audio->Transcode($audioTranscodeParams);
}catch (Zend_Service_Nirvanix_Exception $e) {
	$error = true;
}
				
back to top

Authentication Namespace

The Authentication namespace is used to allow connections into the system. Every connection must first retrieve a session token from the login method. This will allow you to authenticate using a single accounts username and password under a single application.

Login

The Login method is used to login to the system and generate a Session Token restricted to the caller's IP address.

Reference Documentation

C# Example (FlatSDK)

public Session getSession() {
	FlatSDK.Session session = new Session("ABCD-555443-APPKEY-DDEE44",
		"USERNAME",
		"PASSWORD");
	return session;
}
				

Java Example

package com.nirvanix.sdk.session;

class Login {
	public Session getSession() {
		Session session = new Session("ABCD-555443-APPKEY-DDEE44",
			"USERNAME",
			"PASSWORD",
			"APPNAME");
		return session;
	}	
}
				

PHP Example (Zend SDK)

require_once $INCLUDEPATH . '/Zend/Service/Nirvanix.php'; 

// Get Session token for the user/password under the AppKey
$auth = array('username' => $username,'password' => $password,'appKey' => $appkey);
try{
    // This authenticates the user and retrieves session
    $nirvanix = new Zend_Service_Nirvanix($auth);
}catch (Zend_Service_Nirvanix_Exception $e) {
    $error = true;
}
				
back to top

LoginProxy

The LoginProxy method is used to login to the system on behalf of another consumer and generate a Session Token restricted to that consumer's IP address.

Reference Documentation

C# Example (FlatSDK)

public string callLoginProxy() {
	FlatSDK.Authentication auth = new FlatSDK.Authentication();
	string SessionToken = auth.LoginProxy("ABCD-555443-APPKEY-DDEE44",
		"USERNAME",
		"PASSWORD",
		"123.123.123.123");
	return SessionToken;
}
				
back to top

Logout

The Logout method removes a session token from use. This is primarily used for security so when you are finished with a session token it cannot be used by anyone else. This will also allow you to switch the session token when combined with the login if the account is in continuous use such as a background processing application.

Reference Documentation

C# Example (FlatSDK)

public void callLogout() {
	FlatSDK.Session session = new FlatSDK.Session("ABCD-555443-APPKEY-DDEE44",
		"USERNAME",
		"PASSWORD");
	session.Logout();
}
				

Java Example

package com.nirvanix.sdk.session;

class Logout {
	public void callLogout()  throws IOException {
		Session session = new Session("ABCD-555443-APPKEY-DDEE44",
			"USERNAME",
			"PASSWORD",
			"APPNAME");
		session.logout();
	}
}
				

PHP Example (Zend SDK)

require_once $INCLUDEPATH . '/Zend/Service/Nirvanix.php'; 

// Get Session token for the user/password under the AppKey
$auth = array('username' => $username,'password' => $password,'appKey' => $appkey);
try{
	// This authenticates the user and retrieves session
	$nirvanix = new Zend_Service_Nirvanix($auth);
	$nirvanix->getService('Authentication')->logout();
}catch (Zend_Service_Nirvanix_Exception $e) {
	$error = true;
}
				
back to top

ChangePassword

The ChangePassword is used to change an accounts own password.

Reference Documentation

C# Example (FlatSDK)

public void callChangePassword() {
	FlatSDK.Authentication auth = new FlatSDK.Authentication();
	auth.ChangePassword(("ABCD-555443-APPKEY-DDEE44",
		"USERNAME",
		"OLDPASSWORD",
		"NEWPASSWORD");
}
				

Java Example

package com.nirvanix.sdk.session;

class ChangePass {
	public void callChangePassword()  throws NirvanixException,
	                                         SDKException,
	                                         IOException {
		Session session = new Session("ABCD-555443-APPKEY-DDEE44",
			"USERNAME",
			"PASSWORD",
			"APPNAME");
		session.changepassword("NEWPASSWORD");
	}
}
				

PHP Example (Zend SDK)

require_once $INCLUDEPATH . '/Zend/Service/Nirvanix.php'; 

// Get Session token for the user/password under the AppKey
$auth = array('username' => $username,'password' => $password,'appKey' => $appkey);
$newpass = array('username' => $username,
	'oldpassword' => $password,'newpassword' => $newpassword,
	'appKey' => $appkey);
try{
	// This authenticates the user and retrieves session
	$nirvanix = new Zend_Service_Nirvanix($auth);
	$nirvanix->getService('Authentication')->changePassword($newpass);
}catch (Zend_Service_Nirvanix_Exception $e) {
	$error = true;
}
				
back to top

SetChildAccountPassword

The SetChildAccountPassword is used by a master account to set a child accounts password.

Reference Documentation

C# Example (FlatSDK)

public void callSetChildAccountPassword() {
	FlatSDK.Authentication auth = new FlatSDK.Authentication();
	auth.SetChildAccountPassword("ABCD-555443-APPKEY-DDEE44",
		"MASTERACCTUSERNAME",
		"MASTERACCTPASSWORD",
		"CHILDACCTNAME",
		"NEWCHILDACCTPASSWORD");
}
				

Java Example

package com.nirvanix.sdk.session;

class ChangePass {
	public void callSetChildAccountPassword()  throws NirvanixException,
	                                         SDKException,
	                                         IOException {
		// Get the master account session
		Session session = new Session("ABCD-555443-APPKEY-DDEE44",
			"MASTERACCTUSERNAME",
			"MASTERACCTPASSWORD",
			"APPNAME");
		// Get the master account session object.
		MasterAccountSession masterAcct = session.getMasterAccountSession();
		// Set the child accounts password.
		masterAcct.setChildAccountPassword("CHILDUSERNAME",
		            "NEWCHILDACCTPASSWORD");
	}
}
				

PHP Example (Zend SDK)

require_once $INCLUDEPATH . '/Zend/Service/Nirvanix.php'; 

// Get Session token for the user/password under the AppKey
$auth = array('masteracctusername' => $username,'password' => $password,'appKey' => $appkey);
$newpass = array('username' => $masteracctusername,
	'password' => $masteracctpassword,'childAccountPass' => $childpassword,
	'childAccountUsername' => $childusername,'appKey' => $appkey);
try{
	// This authenticates the user and retrieves session
	$nirvanix = new Zend_Service_Nirvanix($auth);
	$nirvanix->getService('Authentication')->setChildAccountPassword($newpass);
}catch (Zend_Service_Nirvanix_Exception $e) {
	$error = true;
}
				
back to top

Image Namespace

The Image namespace allows image manipulation such as resize and rotate.

Resize

Resizes an image creating a new file. The results are returned in a callback.

Reference Documentation

C# Example (FlatSDK)

public void callImageResize() {
	FlatSDK.Session session = new Session("ABCD-555443-APPKEY-DDEE44",
		"USERNAME",
		"PASSWORD");
	FlatSDK.Image image = new FlatSDK.Image(session);
    // Resize an image
	image.ResizeImage("/sourceFilePath/image.jpg",
			"/newDestinationPath/image.jpg",
			50,
			50,
			"http://www.yoursite.com/callbackhandler");
}
				

Java Example

package com.nirvanix.sdk.session;

class ImageResize {
	public void callImageResize()  throws NirvanixException,
	                                         SDKException,
	                                         IOException {
		// Get the session
		Session session = new Session("ABCD-555443-APPKEY-DDEE44",
			"USERNAME",
			"PASSWORD",
			"APPNAME");
		// Get the files in /path/.
		ArrayList files = session.getFolder("/path/", 1, 
		      500, folderSortCode.Name, true).getFiles();
		// Resize image.
		files.get(0).imageResize("/newpath/image.jpg", width, height);
	}
}
				

PHP Example (Zend SDK)

require_once $INCLUDEPATH . '/Zend/Service/Nirvanix.php'; 

// Get Session token for the user/password under the AppKey
$auth = array('username' => $username,'password' => $password,'appKey' => $appkey);

try{
	// This authenticates the user and retrieves session
	$nirvanix = new Zend_Service_Nirvanix($auth);
	// Get image object.
	$image = $nirvanix->getService('Image');
	$resizeParams = array('srcFilePath' => '/sourcepath/image.jpg",
			'destFilePath' => '/destpath/image.jpg",
			'width' => '50',
			'height' => '50',
			'callbackURL' => 'http://www.yoursite.com/callbackhandler.php');
	// Resize the image
	$image->Resize($resizeParams);
}catch (Zend_Service_Nirvanix_Exception $e) {
	$error = true;
}
				
back to top

RotateFlip

The RotateFlip method is used to rotate or flip an existing image. A new image will be created as a result and put into your file system.

Reference Documentation

C# Example (FlatSDK)

public void callImageRotateFlip() {
	FlatSDK.Session session = new Session("ABCD-555443-APPKEY-DDEE44",
		"USERNAME",
		"PASSWORD");
	FlatSDK.Image image = new FlatSDK.Image(session);
    // Rotates / Flips an image
	image.RotateFlipImage("/sourceFilePath/image.jpg",
			"/newDestinationPath/image.jpg",
			RotateType.Rotate90,
			FlipType.FlipHorizontal,
			"http://www.yoursite.com/callbackhandler");
}
				

PHP Example (Zend SDK)

require_once $INCLUDEPATH . '/Zend/Service/Nirvanix.php'; 

// Get Session token for the user/password under the AppKey
$auth = array('username' => $username,'password' => $password,'appKey' => $appkey);

try{
	// This authenticates the user and retrieves session
	$nirvanix = new Zend_Service_Nirvanix($auth);
	// Get image object.
	$image = $nirvanix->getService('Image');
	$rotateflipParams = array('srcFilePath' => '/sourcepath/image.jpg",
			'destFilePath' => '/destpath/image.jpg",
			'rotate' => 'Rotate90',
			'flip' => 'FlipHorizontal',
			'callbackURL' => 'http://www.yoursite.com/callbackhandler.php');
	// Rotate / Flip the image
	$image->RotateFlip($rotateflipParams);
}catch (Zend_Service_Nirvanix_Exception $e) {
	$error = true;
}
				
back to top

Internet Media File System (IMFS) Namespace

The IMFS is responsible for all file operations including copy, move, delete. The SDKs often will wrap calls to the IMFS to return simple file / folder objects and to allow use of simple objects in place of making calls through paths.

CopyFiles

The CopyFiles method is used to copy a file from one location to another. The CopyFiles method can be used to copy one or more files to a given folder. When files are copied, all metadata associated with the original file is also associated with the copied file.

The maximum size for any path is 512 characters. If a file is copied into a folder and the resulting file path is more that 512 characters long, the file will become unusable. Any attempt to access or rename this file, or list the contents of the parnt folder will result in the following error: 70009 - Path is longer than the maximum allowable length of 512.

Reference Documentation

C# Example (FlatSDK)

public void callCopyFiles() {
	FlatSDK.Session session = new Session("ABCD-555443-APPKEY-DDEE44",
		"USERNAME",
		"PASSWORD");
	FlatSDK.IMFS imfs = new FlatSDK.IMFS(session);
	string[] filesToCopy = {"/srcFile.txt", "/subdir/srcFile2.txt"}
	imfs.CopyFiles(filesToCopy, "/destFoldername/");
}
				

Java Example

package com.nirvanix.sdk.session;

class CopyFiles {
	public void callCopyFiles()  throws NirvanixException,
	                                         SDKException,
	                                         IOException {
		// Get the session
		Session session = new Session("ABCD-555443-APPKEY-DDEE44",
			"USERNAME",
			"PASSWORD",
			"APPNAME");
		// get the root folder which will be the destination of the copy.
		Folder destFolder = session.getRootFolder(1, 500, folderSortCode.Name, true);
		// Get the files to copy from the source path.
		ArrayList files = session.getFolder("/srcpath/", 1, 
			500, folderSortCode.Name, true).getFiles();
		// Copy the files to the root from /srcpath/
		destFolder.copyFiles(files);
	}
}
				

PHP Example (Zend SDK)

require_once $INCLUDEPATH . '/Zend/Service/Nirvanix.php'; 

// Get Session token for the user/password under the AppKey
$auth = array('username' => $username,'password' => $password,'appKey' => $appkey);

try{
	// This authenticates the user and retrieves session
	$nirvanix = new Zend_Service_Nirvanix($auth);
	// Get IMFS object.
	$imfs = $nirvanix->getService('IMFS');
	// Setup parameters for file copy.
	$copyFilesParams = array('srcFilePath' => $srcpath,'destFolderPath' => $destFolderPath);
	// Copy file to destination.
	$imfs->copyFiles($copyFilesParams);
}catch (Zend_Service_Nirvanix_Exception $e) {
	$error = true;
}
				
back to top

CopyFolders

The CopyFolders method is used to copy a folder from one location to another. The CopyFolders method can be used to copy one or more folders. Any file that resides within folders that are copied and has metadata associated with it will also have that same metadata associated with the copied files.

The maximum size for any path is 512 characters. When a folder is copied into another folder any resulting file path that is more that 512 characters long will become unusable. Any attempt to access or rename this file or folder, or list the contents of the parent folder, will result in the following error: 70009 - Path is longer than the maximum allowable length of 512.

Reference Documentation

C# Example (FlatSDK)

public void callCopyFolders() {
	FlatSDK.Session session = new Session("ABCD-555443-APPKEY-DDEE44",
		"USERNAME",
		"PASSWORD");
	FlatSDK.IMFS imfs = new FlatSDK.IMFS(session);
	string[] foldersToCopy = {"/srcPath1/", "/srcPath2/"}
	imfs.CopyFolders(foldersToCopy, "/destFoldername/");
}
				

Java Example

package com.nirvanix.sdk.session;

class CopyFolders {
	public void callCopyFolders()  throws NirvanixException,
	                                         SDKException,
	                                         IOException {
		// Get the session
		Session session = new Session("ABCD-555443-APPKEY-DDEE44",
			"USERNAME",
			"PASSWORD",
			"APPNAME");
		// get the root folder which will be the destination of the copy.
		Folder destFolder = session.getRootFolder(1, 500, folderSortCode.Name, true);
		// Get the folders to copy from the source path.
		ArrayList folders = session.getFolder("/srcpath/", 1, 
			500, folderSortCode.Name, true).getFolders();
		// Copy the folders to the root from /srcpath/
		destFolder.copyFolders(folders);
	}
}
				

PHP Example (Zend SDK)

require_once $INCLUDEPATH . '/Zend/Service/Nirvanix.php'; 

// Get Session token for the user/password under the AppKey
$auth = array('username' => $username,'password' => $password,'appKey' => $appkey);

try{
	// This authenticates the user and retrieves session
	$nirvanix = new Zend_Service_Nirvanix($auth);
	// Get IMFS object.
	$imfs = $nirvanix->getService('IMFS');
	// Setup parameters for folder copy.
	$copyFoldersParams = array('srcFolderPath' => $srcFolderPath,'destFolderPath' => $destFolderPath);
	// Copy file to destination.
	$imfs->copyFolders($copyFoldersParams);
}catch (Zend_Service_Nirvanix_Exception $e) {
	$error = true;
}
				
back to top

CreateFolders

The CreateFolder method is used to create a new folder at the specified location.

Reference Documentation

C# Example (FlatSDK)

public void callCreateFolders() {
	FlatSDK.Session session = new Session("ABCD-555443-APPKEY-DDEE44",
		"USERNAME",
		"PASSWORD");
	FlatSDK.IMFS imfs = new FlatSDK.IMFS(session);
	string[] newFolders = {"/newSrcPath1/", "/newSrcPath2/"}
	imfs.CreateFolders(newFolders);
}
				

Java Example

package com.nirvanix.sdk.session;

class CreateFolders {
	public void callCreateFolders()  throws NirvanixException,
	                                         SDKException,
	                                         IOException {
		// Get the session
		Session session = new Session("ABCD-555443-APPKEY-DDEE44",
			"USERNAME",
			"PASSWORD",
			"APPNAME");
		// get the root folder which will be the destination of the create.
		Folder destFolder = session.getRootFolder(1, 500, folderSortCode.Name, true);
		String[] newFolderNames = { "newFolderName1", "newFolderName2" };
		destFolder.createFolders(newFolderNames);
	}
}
				

PHP Example (Zend SDK)

require_once $INCLUDEPATH . '/Zend/Service/Nirvanix.php'; 

// Get Session token for the user/password under the AppKey
$auth = array('username' => $username,'password' => $password,'appKey' => $appkey);

try{
	// This authenticates the user and retrieves session
	$nirvanix = new Zend_Service_Nirvanix($auth);
	// Get IMFS object.
	$imfs = $nirvanix->getService('IMFS');
	// Setup parameters for folder create.
	$createFoldersParams = array('folderPath' => $newFolderPath);
	// Copy file to destination.
	$imfs->createFolders($createFoldersParams);
}catch (Zend_Service_Nirvanix_Exception $e) {
	$error = true;
}
				
back to top

DeleteFiles

The DeleteFiles method is used to remove one or more files.

Reference Documentation

C# Example (FlatSDK)

public void callDeleteFiles() {
	FlatSDK.Session session = new Session("ABCD-555443-APPKEY-DDEE44",
		"USERNAME",
		"PASSWORD");
	FlatSDK.IMFS imfs = new FlatSDK.IMFS(session);
	string[] filesToDelete = {"/testfile1.txt", "/subdir/testfile2.txt"}
	imfs.DeleteFiles(filesToDelete);
}
				

Java Example

package com.nirvanix.sdk.session;

class DeleteFiles {
	public void callDeleteFiles()  throws NirvanixException,
	                                         SDKException,
	                                         IOException {
		// Get the session
		Session session = new Session("ABCD-555443-APPKEY-DDEE44",
			"USERNAME",
			"PASSWORD",
			"APPNAME");
		// Setup an array of file paths to delete.
		String[] filePathsToDelete = { "/FileName1.txt", "/subdir/FileName2.txt" };
		session.deleteFiles(filePathsToDelete)
	}
}
				

PHP Example (Zend SDK)

require_once $INCLUDEPATH . '/Zend/Service/Nirvanix.php'; 

// Get Session token for the user/password under the AppKey
$auth = array('username' => $username,'password' => $password,'appKey' => $appkey);

try{
	// This authenticates the user and retrieves session
	$nirvanix = new Zend_Service_Nirvanix($auth);
	// Get IMFS object.
	$imfs = $nirvanix->getService('IMFS');
	// Setup parameters for file delete.
	$deleteFilesParams = array('filePath' => $filePath);
	// delete file path.
	$imfs->deleteFiles($deleteFilesParams);
}catch (Zend_Service_Nirvanix_Exception $e) {
	$error = true;
}
				
back to top

DeleteFolders

The DeleteFolders method is used to remove one or more folders. Folders will be deleted even if they contain files.

Reference Documentation

C# Example (FlatSDK)

public void callDeleteFolders() {
	FlatSDK.Session session = new Session("ABCD-555443-APPKEY-DDEE44",
		"USERNAME",
		"PASSWORD");
	// get imfs object
	FlatSDK.IMFS imfs = new FlatSDK.IMFS(session);
	// setup array of paths to delete.
	string[] foldersToDelete = {"/newSrcPath1/", "/newSrcPath2/"}
	// delete all paths in the array.
	imfs.DeleteFolders(foldersToDelete);
}
				

Java Example

package com.nirvanix.sdk.session;

class DeleteFiles {
	public void callDeleteFiles()  throws NirvanixException,
	                                         SDKException,
	                                         IOException {
		// Get the session
		Session session = new Session("ABCD-555443-APPKEY-DDEE44",
			"USERNAME",
			"PASSWORD",
			"APPNAME");
		// Setup an array of paths to delete.
		String[] folderPathsToDelete = { "/newFolderName1", "/subdir/newFolderName2" };
		// delete all paths in the array.
		session.deleteFolders(folderPathsToDelete)
	}
}
				

PHP Example (Zend SDK)

require_once $INCLUDEPATH . '/Zend/Service/Nirvanix.php'; 

// Get Session token for the user/password under the AppKey
$auth = array('username' => $username,'password' => $password,'appKey' => $appkey);

try{
	// This authenticates the user and retrieves session
	$nirvanix = new Zend_Service_Nirvanix($auth);
	// Get IMFS object.
	$imfs = $nirvanix->getService('IMFS');
	// Setup parameters for folder delete.
	$deleteFoldersParams = array('folderPath' => $folderPath);
	// delete folder path.
	$imfs->deleteFolders($deleteFoldersParams);
}catch (Zend_Service_Nirvanix_Exception $e) {
	$error = true;
}
				
back to top

GetPathInfo

The GetPathInfo method is used to retrieve information about an existing file or folder. It provides some basic information about the item, such as the file size, whether the path is a file or folder, metadata, tags, created date, and last modification date.

Reference Documentation

C# Example (FlatSDK)

public void callGetPathInfo() {
	FlatSDK.Session session = new Session("ABCD-555443-APPKEY-DDEE44",
		"USERNAME",
		"PASSWORD");
	// get imfs object
	FlatSDK.IMFS imfs = new FlatSDK.IMFS(session);
	IItem item = GetPathInfo("/subdir/file.txt",
		true, 
		true,
		true);
	// if the returned item is a File get the file type.  
	// File or Folder can be returned from GetPathInfo.
	if (item is IFile) {
		string type = (item as IFile).FileType;
	}
}
				

PHP Example (Zend SDK)

require_once $INCLUDEPATH . '/Zend/Service/Nirvanix.php'; 

// Get Session token for the user/password under the AppKey
$auth = array('username' => $username,'password' => $password,'appKey' => $appkey);

try{
	// This authenticates the user and retrieves session
	$nirvanix = new Zend_Service_Nirvanix($auth);
	// Get IMFS object.
	$imfs = $nirvanix->getService('IMFS');
	// Setup parameters for getPathInfo.
	$getPathInfoParams = array('itemPath' => $itemPath,'showMetadata' => 'true',
		'showTags' => 'true','showIsShared' => 'true');
	$results = $imfs->getPathInfo($getPathInfoParams);
	print_r($results);
}catch (Zend_Service_Nirvanix_Exception $e) {
	$error = true;
}
				
back to top

ListFolder

The ListFolder method is used to describe the contents of a folder. It lists the files and folders as well as some basic information about the items, such as the file size, metadata, tags and created date. This call supports paging.

Reference Documentation

C# Example (FlatSDK)

public void callListFolder() {
	FlatSDK.Session session = new Session("ABCD-555443-APPKEY-DDEE44",
		"USERNAME",
		"PASSWORD");
	// get imfs object
	FlatSDK.IMFS imfs = new FlatSDK.IMFS(session);
	// call list folder on a single path.
	IListFolder listReturn = imfs.ListFolder("/folderpath/",
				1,
				500,
				FolderSortCode.Name,
				true);
}
				

Java Example

package com.nirvanix.sdk.session;

class ListFolder {
	public void callListFolder()  throws NirvanixException,
	                                         SDKException,
	                                         IOException {
		// Get the session
		Session session = new Session("ABCD-555443-APPKEY-DDEE44",
			"USERNAME",
			"PASSWORD",
			"APPNAME");
		// Get the root folder which will call list folder on "/"
		Folder destFolder = session.getRootFolder(1, 500, folderSortCode.Name, true);
	}
}
				

PHP Example (Zend SDK)

require_once $INCLUDEPATH . '/Zend/Service/Nirvanix.php'; 

// Get Session token for the user/password under the AppKey
$auth = array('username' => $username,'password' => $password,'appKey' => $appkey);

try{
	// This authenticates the user and retrieves session
	$nirvanix = new Zend_Service_Nirvanix($auth);
	// Get IMFS object.
	$imfs = $nirvanix->getService('IMFS');
	// Setup parameters for folder delete.
	$listFolderParams = array('folderPath' => $folderPath,'pageNumber' => '1',
		'pageSize' => 500,'sortCode' => 'Name','sortDescending' => 'true');
	// call listfolder and write the xml / object results to the output.
	$results = $imfs->listFolder($listFolderParams);
	print_r($results);
}catch (Zend_Service_Nirvanix_Exception $e) {
	$error = true;
}
				
back to top

MoveFiles

The MoveFiles method is used to move a file from one location to another. The MoveFiles method can be used to move one or more files to a given folder.

The maximum size for any path is 512 characters. If a file is moved into a folder and the resulting file path is more that 512 characters long, the file will become unusable. Any attempt to access or rename this file, or list the contents of the parent folder will result in the following error: 70009 - Path is longer than the maximum allowable length of 512.

Reference Documentation

C# Example (FlatSDK)

public void callMoveFiles() {
	FlatSDK.Session session = new Session("ABCD-555443-APPKEY-DDEE44",
		"USERNAME",
		"PASSWORD");
	FlatSDK.IMFS imfs = new FlatSDK.IMFS(session);
	string[] filesToMove = {"/srcFile.txt", "/subdir/srcFile2.txt"}
	imfs.MoveFiles(filesToMove, "/destFoldername/");
}
				

Java Example

package com.nirvanix.sdk.session;

class MoveFiles {
	public void callMoveFiles()  throws NirvanixException,
	                                         SDKException,
	                                         IOException {
		// Get the session
		Session session = new Session("ABCD-555443-APPKEY-DDEE44",
			"USERNAME",
			"PASSWORD",
			"APPNAME");
		// get the root folder which will be the destination of the move.
		Folder destFolder = session.getRootFolder(1, 500, folderSortCode.Name, true);
		// Get the files to move from the source path.
		ArrayList files = session.getFolder("/srcpath/", 1, 
			500, folderSortCode.Name, true).getFiles();
		// Move the files to the root from /srcpath/
		destFolder.moveFiles(files);
	}
}
				

PHP Example (Zend SDK)

require_once $INCLUDEPATH . '/Zend/Service/Nirvanix.php'; 

// Get Session token for the user/password under the AppKey
$auth = array('username' => $username,'password' => $password,'appKey' => $appkey);

try{
	// This authenticates the user and retrieves session
	$nirvanix = new Zend_Service_Nirvanix($auth);
	// Get IMFS object.
	$imfs = $nirvanix->getService('IMFS');
	// Setup parameters for file move.
	$moveFilesParams = array('srcFilePath' => $srcpath,'destFolderPath' => $destFolderPath);
	// Move file to destination.
	$imfs->moveFiles($moveFilesParams);
}catch (Zend_Service_Nirvanix_Exception $e) {
	$error = true;
}
				
back to top

MoveFolders

The MoveFolders method is used to move a folder from one location to another. The MoveFolders method can be used to move one or more folders.

The maximum size for any path is 512 characters. When a folder is copied into another folder any resulting file path that is more that 512 characters long will become unusable. Any attempt to access or rename this file or folder, or list the contents of the parent folder will result in the following error: 70009 - Path is longer than the maximum allowable length of 512.

Reference Documentation

C# Example (FlatSDK)

public void callMoveFolders() {
	FlatSDK.Session session = new Session("ABCD-555443-APPKEY-DDEE44",
		"USERNAME",
		"PASSWORD");
	FlatSDK.IMFS imfs = new FlatSDK.IMFS(session);
	string[] foldersToMove = {"/srcPath1/", "/srcPath2/"}
	imfs.MoveFolders(foldersToMove, "/destFoldername/");
}
				

Java Example

package com.nirvanix.sdk.session;

class MoveFolders {
	public void callMoveFolders()  throws NirvanixException,
	                                         SDKException,
	                                         IOException {
		// Get the session
		Session session = new Session("ABCD-555443-APPKEY-DDEE44",
			"USERNAME",
			"PASSWORD",
			"APPNAME");
		// get the root folder which will be the destination of the move.
		Folder destFolder = session.getRootFolder(1, 500, folderSortCode.Name, true);
		// Get the folders to move from the source path.
		ArrayList folders = session.getFolder("/srcpath/", 1, 
			500, folderSortCode.Name, true).getFolders();
		// Move the folders to the root from /srcpath/
		destFolder.moveFolders(folders);
	}
}
				

PHP Example (Zend SDK)

require_once $INCLUDEPATH . '/Zend/Service/Nirvanix.php'; 

// Get Session token for the user/password under the AppKey
$auth = array('username' => $username,'password' => $password,'appKey' => $appkey);

try{
	// This authenticates the user and retrieves session
	$nirvanix = new Zend_Service_Nirvanix($auth);
	// Get IMFS object.
	$imfs = $nirvanix->getService('IMFS');
	// Setup parameters for folder move.
	$moveFoldersParams = array('srcFolderPath' => $srcFolderPath,'destFolderPath' => $destFolderPath);
	// Move file to destination.
	$imfs->moveFolders($moveFoldersParams);
}catch (Zend_Service_Nirvanix_Exception $e) {
	$error = true;
}
				
back to top

RenameFile

The RenameFile method is used to rename a file from one name to another.

Reference Documentation

C# Example (FlatSDK)

public void callRenameFile() {
	FlatSDK.Session session = new Session("ABCD-555443-APPKEY-DDEE44",
		"USERNAME",
		"PASSWORD");
	FlatSDK.IMFS imfs = new FlatSDK.IMFS(session);
	imfs.RenameFile("newFilename.txt", "/subdir/filetorename.txt");
}
				

Java Example

package com.nirvanix.sdk.session;

class RenameFile {
	public void callRenameFile()  throws NirvanixException,
	                                         SDKException,
	                                         IOException {
		// Get the session
		Session session = new Session("ABCD-555443-APPKEY-DDEE44",
			"USERNAME",
			"PASSWORD",
			"APPNAME");
		// Get the files in /srcpath/.
		ArrayList files = session.getFolder("/srcpath/", 1, 
			500, folderSortCode.Name, true).getFiles();
		// rename the first file in the file list.
		files.get(0).Rename("newName");
	}
}
				

PHP Example (Zend SDK)

require_once $INCLUDEPATH . '/Zend/Service/Nirvanix.php'; 

// Get Session token for the user/password under the AppKey
$auth = array('username' => $username,'password' => $password,'appKey' => $appkey);

try{
	// This authenticates the user and retrieves session
	$nirvanix = new Zend_Service_Nirvanix($auth);
	// Get IMFS object.
	$imfs = $nirvanix->getService('IMFS');
	// Setup parameters for file rename.
	$renameFileParams = array('filePath' => $srcFilePath,'newFilename' => $newFilename);
	// rename the src file to the new filename.
	$imfs->renameFile($renameFileParams);
}catch (Zend_Service_Nirvanix_Exception $e) {
	$error = true;
}
				
back to top

RenameFolder

The RenameFolder method is used to rename a folder from one name to another.

Reference Documentation

C# Example (FlatSDK)

public void callRenameFolder() {
	FlatSDK.Session session = new Session("ABCD-555443-APPKEY-DDEE44",
		"USERNAME",
		"PASSWORD");
	FlatSDK.IMFS imfs = new FlatSDK.IMFS(session);
	imfs.RenameFolder("newFolderName", "/srcPath/");
}
				

Java Example

package com.nirvanix.sdk.session;

class RenameFolder {
	public void callRenameFolder()  throws NirvanixException,
	                                         SDKException,
	                                         IOException {
		// Get the session
		Session session = new Session("ABCD-555443-APPKEY-DDEE44",
			"USERNAME",
			"PASSWORD",
			"APPNAME");
		// Get the folders to rename from the source path.
		com.nirvanix.sdk.session.Folder folder = session.getFolder("/srcpath/", 1, 
			500, folderSortCode.Name, true);
		// rename the folder.
		folder.Rename("newFolderName");
	}
}
				

PHP Example (Zend SDK)

require_once $INCLUDEPATH . '/Zend/Service/Nirvanix.php'; 

// Get Session token for the user/password under the AppKey
$auth = array('username' => $username,'password' => $password,'appKey' => $appkey);

try{
	// This authenticates the user and retrieves session
	$nirvanix = new Zend_Service_Nirvanix($auth);
	// Get IMFS object.
	$imfs = $nirvanix->getService('IMFS');
	// Setup parameters for folder rename.
	$renameFolderParams = array('folderPath' => $srcFolderPath,
		'newFoldername' => $newFoldername);
	// rename the src folder to the new folder name.
	$imfs->renameFolder($renameFolderParams);
}catch (Zend_Service_Nirvanix_Exception $e) {
	$error = true;
}
				
back to top

GetDownloadNodes

The GetDownloadNodes method is used to get the storage node location for one or more files.

Reference Documentation

C# Example (FlatSDK)

public void callGetDownloadNodes() {
	FlatSDK.Session session = new Session("ABCD-555443-APPKEY-DDEE44",
		"USERNAME",
		"PASSWORD");
	FlatSDK.IMFS imfs = new FlatSDK.IMFS(session);
	string[] paths = new string[] { "My Folder/My File 1.txt",  "My Folder/My File 2.txt" };
	string[] downloadNodes = imfs.GetDownloadNodes(paths);
}
				

Java Example

public void callGetDownloadNodes()
    throws NirvanixException, 
        SDKException,
        java.io.IOException, Exception {
    APIParam[] loginParams = { new APIParam("appKey", "yourappkey"),
        new APIParam("username", "yourusername"), 
        new APIParam("password", "yourpassword") 
    };
    
    Element xmlData = Transport.executeCommand("Authentication", "Login", loginParams, true);
    String sessionToken = xmlData.getFirstChildElement("SessionToken").getValue();

    APIParam[] getDownloadNodesParams = { new APIParam("sessionToken", sessionToken),
                            new APIParam("filePath", "My Folder/My File 2.txt" ),
    };
    xmlData = Transport.executeCommand("IMFS", "GetDownloadNodes", getDownloadNodesParams, false);

    String downloadNode = xmlData.getFirstChildElement("DownloadNode").getValue();
}
				

PHP Example (Zend SDK)

require_once $INCLUDEPATH . '/Zend/Service/Nirvanix.php'; 

// Get Session token for the user/password under the AppKey
$auth = array('username' => $username,'password' => $password,'appKey' => $appkey);

try{
	// This authenticates the user and retrieves session
	$nirvanix = new Zend_Service_Nirvanix($auth);
	// Get IMFS object.
	$imfs = $nirvanix->getService('IMFS');
	// Setup parameters for getdownloadnodes.
	$downloadNodesParams = array('filePath' => $filePath);
	// Get Download Nodes
	$results = $imfs->GetDownloadNodes($downloadNodesParams);
	print_r($results);
}catch (Zend_Service_Nirvanix_Exception $e) {
	$error = true;
}
				
back to top

GetOptimalUrls

The GetoptimalUrls method is used to retrieve a URL to a specific file using a tokenized url with a set expiration that can be locked to a specific IP address.

Reference Documentation

C# Example (FlatSDK)

public void callGetOptimalURLs() {
	FlatSDK.Session session = new Session("ABCD-555443-APPKEY-DDEE44",
		"USERNAME",
		"PASSWORD");
	FlatSDK.IMFS imfs = new FlatSDK.IMFS(session);
	string[] paths = new string[] { "My Folder/My File 1.txt",  "My Folder/My File 2.txt" };
	string[] downloadNodes = imfs.GetOptimalURLs(paths);
}
				

Java Example

public void callGetOptimalURLsDownload()
    throws NirvanixException, 
        SDKException,
        java.io.IOException, Exception {
    APIParam[] loginParams = { new APIParam("appKey", "yourappkey"),
        new APIParam("username", "yourusername"), 
        new APIParam("password", "yourpassword") 
    };
    
    Element xmlData = Transport.executeCommand("Authentication", "Login", loginParams, true);
    String sessionToken = xmlData.getFirstChildElement("SessionToken").getValue();

    APIParam[] getOptimalURLsParams = { new APIParam("sessionToken", sessionToken),
                            new APIParam("filePath", "My Folder/My File 2.txt"),
                            new APIParam("expiration", "1000")
    };
    xmlData = Transport.executeCommand("IMFS", "GetOptimalURLs", getOptimalURLsParams, false);

    Element downloadResp = xmlData.getFirstChildElement("Download");

    String downloadURL = downloadResp.getFirstChildElement("DownloadURL").getValue();
}
				

PHP Example (Zend SDK)

require_once $INCLUDEPATH . '/Zend/Service/Nirvanix.php'; 

// Get Session token for the user/password under the AppKey
$auth = array('username' => $username,'password' => $password,'appKey' => $appkey);

try{
	// This authenticates the user and retrieves session
	$nirvanix = new Zend_Service_Nirvanix($auth);
	// Get IMFS object.
	$imfs = $nirvanix->getService('IMFS');
	// Setup parameters for getoptimalurls.
	$getOptimalUrlsParams = array('filePath' => "My Folder/My File 2.txt", 'expiration' => "1000");
	// call get optimal urls.
	$results = $imfs->getOptimalURLs($getOptimalUrlsParams);
	print_r($results);
}catch (Zend_Service_Nirvanix_Exception $e) {
	$error = true;
}
				
back to top

GetStorageNodeExtended

Gets the closest available node from your current location and an upload token for doing an upload.

Reference Documentation

C# Example (FlatSDK)

public void callGetStorageNodeExtended() {
	FlatSDK.Session session = new Session("ABCD-555443-APPKEY-DDEE44",
		"USERNAME",
		"PASSWORD");
	FlatSDK.IMFS imfs = new FlatSDK.IMFS(session);
	GetStorageNode storageNode = imfs.GetStorageNodeExtended(160034,
			"101.101.101.10", // Your IP Address
			true,	// If the token should be locked to that IP.
			"/uploadfolder",  // The folder where you will be uploading to (if it doesn't exist it will be created)
			true,		// If the upload is allowed to overwrite files with the same name in the destination directory.
			1000,		// First and last byte expiration.
			64000);
}
				

Java Example

// This is normally done automatically through the Uploader interface.
...

APIParam[] getStorageNodeParams = { new APIParam("sessionToken", sessionToken),
                        new APIParam("sizeBytes", "1000"),
                        new APIParam("destFolderPath", Config.TESTFOLDER),
                        new APIParam("fileOverwrite", "true")
};

xmlData = Transport.executeCommand("IMFS", "GetStorageNodeExtended", getStorageNodeParams, false);

Element getStorageNode = xmlData.getFirstChildElement("GetStorageNode");

String uploadHost = getStorageNode.getFirstChildElement("UploadHost").getValue();
String uploadToken = getStorageNode.getFirstChildElement("UploadToken").getValue();

...

				

PHP Example (Zend SDK)

require_once $INCLUDEPATH . '/Zend/Service/Nirvanix.php'; 

// Get Session token for the user/password under the AppKey
$auth = array('username' => $username,'password' => $password,'appKey' => $appkey);

try{
	// This authenticates the user and retrieves session
	$nirvanix = new Zend_Service_Nirvanix($auth);
	// Get IMFS object.
	$imfs = $nirvanix->getService('IMFS');
	// Setup parameters for get storage node extended
	// Common question on size bytes, if doing a web upload pass a average file size.
	$getStorageNodeExtendedParams = array('sizeBytes' => "10000", 
		'consumerIP' => '101.101.101.10',
		'ipRestricted' => 'true',
		'destFolderPath' => '/uploadfolder',
		'fileOverwrite' => 'true');
	// Call getStorageNodeExtended
	$results = $imfs->getStorageNodeExtended($getStorageNodeExtendedParams);
	print_r($results);
}catch (Zend_Service_Nirvanix_Exception $e) {
	$error = true;
}
				
back to top

GetStorageNode

Gets the closest available node from your current location and an upload token for doing an upload.

Reference Documentation

PHP Example (Zend SDK)

require_once $INCLUDEPATH . '/Zend/Service/Nirvanix.php'; 

// Get Session token for the user/password under the AppKey
$auth = array('username' => $username,'password' => $password,'appKey' => $appkey);

try{
	// This authenticates the user and retrieves session
	$nirvanix = new Zend_Service_Nirvanix($auth);
	// Get IMFS object.
	$imfs = $nirvanix->getService('IMFS');
	// Setup parameters for get storage node
	// Common question on size bytes, if doing a web upload pass a average file size.
	$getStorageNodeParams = array('sizeBytes' => "10000", 
		'restrictedIP' => '101.101.101.10');
	// Call getStorageNode
	$results = $imfs->getStorageNode($getStorageNodeParams);
	print_r($results);	
}catch (Zend_Service_Nirvanix_Exception $e) {
	$error = true;
}
				
back to top

SearchFileSystem

Gets the closest available node from your current location and an upload token for doing an upload.

Reference Documentation

C# Example (FlatSDK)

public void callSearchFileSystem() {
	FlatSDK.Session session = new Session("ABCD-555443-APPKEY-DDEE44",
		"USERNAME",
		"PASSWORD");
	FlatSDK.IMFS imfs = new FlatSDK.IMFS(session);
	SearchResults SearchFileSystem("flower*",
			"usertosearch",
			FileType.Image,
			0,
			100000000,
			new DateTime("1/1/2009"),
			DateTime.Now,
			500);
}
				

Java Example

package com.nirvanix.sdk.session;

class doSearchFileSystem {
	public void callSearchFileSystem()  throws NirvanixException,
	                                         SDKException,
	                                         IOException {
		// Get the session
		Session session = new Session("ABCD-555443-APPKEY-DDEE44",
			"USERNAME",
			"PASSWORD",
			"APPNAME");
		// Search for image files starting with flower
		String searchTerm = "flower*";
        FileType fileType = FileType.Image;
        long minFileSize = 0L;
        long maxFileSize = 0L;
        Calendar minCreatedCalendar = new GregorianCalendar();
        
        // set it to a year ago
        minCreatedCalendar.roll(Calendar.YEAR, false);
        
        Date maxCreatedDate = new Date();
        Date minCreatedDate = minCreatedCalendar.getTime();
        int maxResults = 10000;
        
		SearchResults result = this.instance.SearchFileSystem(searchTerm,
                    fileType,
                    minFileSize,
                    maxFileSize,
                    minCreatedDate,
                    maxCreatedDate,
                    maxResults);
	}
}

				

PHP Example (Zend SDK)

require_once $INCLUDEPATH . '/Zend/Service/Nirvanix.php'; 

// Get Session token for the user/password under the AppKey
$auth = array('username' => $username,'password' => $password,'appKey' => $appkey);

try{
	// This authenticates the user and retrieves session
	$nirvanix = new Zend_Service_Nirvanix($auth);
	// Get IMFS object.
	$imfs = $nirvanix->getService('IMFS');
	// Setup parameters for get storage node extended
	// Common question on size bytes, if doing a web upload pass a average file size.
	$searchParams = array('searchTerm' => "flower*", 
		'username' => $username,
		'fileType' => 'Image',
		'minFileSize' => '0',
		'maxFileSize' => '0',
		'minCreatedDate' => '1/30/2009',
		'maxCreatedDate' => '1/30/2011',
		'maxResults' => '10000');
	// Call SearchFileSystem
	$results = $imfs->SearchFileSystem($searchParams);
	print_r($results);
}catch (Zend_Service_Nirvanix_Exception $e) {
	$error = true;
}
				
back to top

Sideload

Calls a background process to download the file at the provided URL directly into your account.

Reference Documentation

C# Example (FlatSDK)


public void callSideload() {
	FlatSDK.Session session = new Session("ABCD-555443-APPKEY-DDEE44",
		"USERNAME",
		"PASSWORD");
	FlatSDK.IMFS imfs = new FlatSDK.IMFS(session);
	SideloadUrl("http://www.yoursite.com/path/file.txt",
			"/downloads/file.txt",
			"http://www.yoursite.com/callbackhandler")
}
				

Java Example

package com.nirvanix.sdk.session;

class doSideload {
	public void callSideload()  throws NirvanixException,
	                                         SDKException,
	                                         IOException {
		// Get the session
		Session session = new Session("ABCD-555443-APPKEY-DDEE44",
			"USERNAME",
			"PASSWORD",
			"APPNAME");
		// Download files from your site into your account.
		session.sideload({ "http://www.yoursite.com/path/file.txt" }, "/download/file.txt");		
}

				

PHP Example (Zend SDK)

require_once $INCLUDEPATH . '/Zend/Service/Nirvanix.php'; 

// Get Session token for the user/password under the AppKey
$auth = array('username' => $username,'password' => $password,'appKey' => $appkey);

try{
	// This authenticates the user and retrieves session
	$nirvanix = new Zend_Service_Nirvanix($auth);
	// Get IMFS object.
	$imfs = $nirvanix->getService('IMFS');
	// Setup parameters for get storage node extended
	// Common question on size bytes, if doing a web upload pass a average file size.
	$sideloadParams = array('targetURL' => "http://www.yoursite.com/path/file.txt", 
		'destFilePath' => "/download/file.txt",
		'callbackURL' => 'http://www.yoursite.com/callbackhandler.php');
	// Call Sideload
	$imfs->Sideload($sideloadParams);
}catch (Zend_Service_Nirvanix_Exception $e) {
	$error = true;
}
				
back to top

Metadata Namespace

Metadata is stored for all files and folders. The Metadata is stored as name / value pair.

DeleteAllMetadata

Removes all Metadata from a single file or folder except the MD5 which is part of the base system Metadata and cannot be modified.

Reference Documentation

C# Example (FlatSDK)

public void callDeleteAllMetadata() {
	FlatSDK.Session session = new Session("ABCD-555443-APPKEY-DDEE44",
		"USERNAME",
		"PASSWORD");
	FlatSDK.Metadata metadata = new FlatSDK.Metadata(session);

	metadata.DeleteAllMetadata("/path/file.txt");
}
				

Java Example

package com.nirvanix.sdk.session;

class DeleteAllMetadata {
	public void callDeleteAllMetadata()  throws NirvanixException,
	                                         SDKException,
	                                         IOException {
		// Get the session
		Session session = new Session("ABCD-555443-APPKEY-DDEE44",
			"USERNAME",
			"PASSWORD",
			"APPNAME");
		// Get the files in /path/.
		ArrayList files = session.getFolder("/path/", 1, 
			500, folderSortCode.Name, true).getFiles();
		// Delete all of the metadata for the first file in the file list.
		files.get(0).deleteAllMetadata();
	}
}
				

PHP Example (Zend SDK)

require_once $INCLUDEPATH . '/Zend/Service/Nirvanix.php'; 

// Get Session token for the user/password under the AppKey
$auth = array('username' => $username,'password' => $password,'appKey' => $appkey);

try{
	// This authenticates the user and retrieves session
	$nirvanix = new Zend_Service_Nirvanix($auth);
	// Get Metadata object.
	$metadata = $nirvanix->getService('Metadata');
	// delete all metadata for /path/file.txt.
	$metadata->DeleteAllMetadata(array('path' => '/path/file.txt'));
}catch (Zend_Service_Nirvanix_Exception $e) {
	$error = true;
}
				
back to top

DeleteMetadata

Removes Metadata from a single file or folder that matches the passed key except the MD5 which is part of the base system Metadata and cannot be modified.

Reference Documentation

C# Example (FlatSDK)

public void callDeleteMetadata() {
	FlatSDK.Session session = new Session("ABCD-555443-APPKEY-DDEE44",
		"USERNAME",
		"PASSWORD");
	FlatSDK.Metadata metadata = new FlatSDK.Metadata(session);
	String[] keyToDelete = { "keytodelete" };
	metadata.DeleteMetadata("/path/file.txt", keyToDelete);
}
				

Java Example

package com.nirvanix.sdk.session;

class DeleteMetadata {
	public void callDeleteAllMetadata()  throws NirvanixException,
	                                         SDKException,
	                                         IOException {
		// Get the session
		Session session = new Session("ABCD-555443-APPKEY-DDEE44",
			"USERNAME",
			"PASSWORD",
			"APPNAME");
		// Get the files in /path/.
		ArrayList files = session.getFolder("/path/", 1, 
			500, folderSortCode.Name, true).getFiles();
		// Delete metadata for the first file in the file list based on the key.
		String[] metadataToDelete = { "myKey" };
		files.get(0).deleteMetadata(metadataToDelete);
	}
}
				

PHP Example (Zend SDK)

require_once $INCLUDEPATH . '/Zend/Service/Nirvanix.php'; 

// Get Session token for the user/password under the AppKey
$auth = array('username' => $username,'password' => $password,'appKey' => $appkey);

try{
	// This authenticates the user and retrieves session
	$nirvanix = new Zend_Service_Nirvanix($auth);
	// Get Metadata object.
	$metadata = $nirvanix->getService('Metadata');
	// delete metadata for /path/file.txt based on the key.
	$metadata->DeleteMetadata(array('path' => '/path/file.txt', 'metadata' => "keytodelete"));
}catch (Zend_Service_Nirvanix_Exception $e) {
	$error = true;
}
				
back to top

GetMetadata

Retrieves all Metadata from a single file or folder.

Reference Documentation

C# Example (FlatSDK)

public void callGetMetadata() {
	FlatSDK.Session session = new Session("ABCD-555443-APPKEY-DDEE44",
		"USERNAME",
		"PASSWORD");
	FlatSDK.Metadata metadata = new FlatSDK.Metadata(session);

	Dictionary metadataResults = metadata.GetMetadata("/path/file.txt");
}
				

Java Example

package com.nirvanix.sdk.session;

class GetMetadata {
	public void callGetAllMetadata()  throws NirvanixException,
	                                         SDKException,
	                                         IOException {
		// Get the session
		Session session = new Session("ABCD-555443-APPKEY-DDEE44",
			"USERNAME",
			"PASSWORD",
			"APPNAME");
		// Get the files in /path/.
		ArrayList files = session.getFolder("/path/", 1, 
			500, folderSortCode.Name, true).getFiles();
		// Get all metadata for the first file in the file list.
		MetadataInfo[] result = files.get(0).getMetadata();
	}
}
				

PHP Example (Zend SDK)

require_once $INCLUDEPATH . '/Zend/Service/Nirvanix.php'; 

// Get Session token for the user/password under the AppKey
$auth = array('username' => $username,'password' => $password,'appKey' => $appkey);

try{
	// This authenticates the user and retrieves session
	$nirvanix = new Zend_Service_Nirvanix($auth);
	// Get Metadata object.
	$metadata = $nirvanix->getService('Metadata');
	// get metadata for /path/file.txt.
	$results = $metadata->GetMetadata(array('path' => '/path/file.txt'));
	print_r($results);
}catch (Zend_Service_Nirvanix_Exception $e) {
	$error = true;
}
				
back to top

SetMetadata

Sets Metadata for a single file or folder.

Reference Documentation

C# Example (FlatSDK)


public void callSetMetadata() {
	FlatSDK.Session session = new Session("ABCD-555443-APPKEY-DDEE44",
		"USERNAME",
		"PASSWORD");
	FlatSDK.Metadata metadata = new FlatSDK.Metadata(session);

	Dictionary newMetadata = new Dictionary();

	string key = "yourkey";
	string value = "Your Value";

	newMetadata.Add(key, value);

	// sets the metadata
	metadata.SetMetadata("/path/file.txt", newMetadata);
}

				

Java Example


package com.nirvanix.sdk.session;

class SetMetadata {
	public void callSetAllMetadata()  throws NirvanixException,
	                                         SDKException,
	                                         IOException {
		// Get the session
		Session session = new Session("ABCD-555443-APPKEY-DDEE44",
			"USERNAME",
			"PASSWORD",
			"APPNAME");
		// Get the files in /path/.
		ArrayList files = session.getFolder("/path/", 1, 
			500, folderSortCode.Name, true).getFiles();
		
		// Set metadata for the first file in the file list.
		MetadataInfo[] metaDataInfo = { new MetadataInfo("yourkey", "Your Value") };
		files.get(0).setMetadata(metaDataInfo);
	}
}
				

PHP Example (Zend SDK)

require_once $INCLUDEPATH . '/Zend/Service/Nirvanix.php'; 

// Get Session token for the user/password under the AppKey
$auth = array('username' => $username,'password' => $password,'appKey' => $appkey);

try{
	// This authenticates the user and retrieves session
	$nirvanix = new Zend_Service_Nirvanix($auth);
	// Get Metadata object.
	$metadata = $nirvanix->getService('Metadata');
	// set metadata for /path/file.txt.
	$metadata->SetMetadata(array('path' => '/path/file.txt', 'metadata' => 'yourkey:Your Value'));
}catch (Zend_Service_Nirvanix_Exception $e) {
	$error = true;
}
				
back to top

DeleteAllTags

Removes all tags from a single file or folder.

Reference Documentation

C# Example (FlatSDK)

public void callDeleteAllTags() {
	FlatSDK.Session session = new Session("ABCD-555443-APPKEY-DDEE44",
		"USERNAME",
		"PASSWORD");
	FlatSDK.Metadata metadata = new FlatSDK.Metadata(session);

	metadata.DeleteAllTags("/path/file.txt");
}
				

Java Example

package com.nirvanix.sdk.session;

class DeleteAllTags {
	public void callDeleteAllTags()  throws NirvanixException,
	                                         SDKException,
	                                         IOException {
		// Get the session
		Session session = new Session("ABCD-555443-APPKEY-DDEE44",
			"USERNAME",
			"PASSWORD",
			"APPNAME");
		// Get the files in /path/.
		ArrayList files = session.getFolder("/path/", 1, 
			500, folderSortCode.Name, true).getFiles();
		// Delete all of the tags for the first file in the file list.
		files.get(0).deleteAllTags();
	}
}
				

PHP Example (Zend SDK)

require_once $INCLUDEPATH . '/Zend/Service/Nirvanix.php'; 

// Get Session token for the user/password under the AppKey
$auth = array('username' => $username,'password' => $password,'appKey' => $appkey);

try{
	// This authenticates the user and retrieves session
	$nirvanix = new Zend_Service_Nirvanix($auth);
	// Get Metadata object.
	$metadata = $nirvanix->getService('Metadata');
	// delete all tags for /path/file.txt.
	$metadata->DeleteAllTags(array('path' => '/path/file.txt'));
}catch (Zend_Service_Nirvanix_Exception $e) {
	$error = true;
}
				
back to top

DeleteTags

Removes Tags from a single file or folder that matches the passed key.

Reference Documentation

C# Example (FlatSDK)

public void callDeleteTags() {
	FlatSDK.Session session = new Session("ABCD-555443-APPKEY-DDEE44",
		"USERNAME",
		"PASSWORD");
	FlatSDK.Metadata metadata = new FlatSDK.Metadata(session);
	String[] tagToDelete = { "sometag" };
	metadata.DeleteTags("/path/file.txt", tagToDelete);
}
				

Java Example

package com.nirvanix.sdk.session;

class DeleteTags {
	public void callDeleteAllTags()  throws NirvanixException,
	                                         SDKException,
	                                         IOException {
		// Get the session
		Session session = new Session("ABCD-555443-APPKEY-DDEE44",
			"USERNAME",
			"PASSWORD",
			"APPNAME");
		// Get the files in /path/.
		ArrayList files = session.getFolder("/path/", 1, 
			500, folderSortCode.Name, true).getFiles();
		// Delete tag for the first file in the file list based on the key.
		String[] tagToDelete = { "sometag" };
		files.get(0).deleteTags(tagToDelete);
	}
}
				

PHP Example (Zend SDK)

require_once $INCLUDEPATH . '/Zend/Service/Nirvanix.php'; 

// Get Session token for the user/password under the AppKey
$auth = array('username' => $username,'password' => $password,'appKey' => $appkey);

try{
	// This authenticates the user and retrieves session
	$nirvanix = new Zend_Service_Nirvanix($auth);
	// Get Metadata object.
	$metadata = $nirvanix->getService('Metadata');
	// delete tag for /path/file.txt based on the key.
	$metadata->DeleteTags(array('path' => '/path/file.txt', 'tag' => "sometag"));
}catch (Zend_Service_Nirvanix_Exception $e) {
	$error = true;
}
				
back to top

GetTags

Retrieves all tags from a single file or folder.

Reference Documentation

C# Example (FlatSDK)

public void callGetTags() {
	FlatSDK.Session session = new Session("ABCD-555443-APPKEY-DDEE44",
		"USERNAME",
		"PASSWORD");
	FlatSDK.Metadata metadata = new FlatSDK.Metadata(session);

	string[] tags = metadata.GetTags("/path/file.txt");
}
				

Java Example

package com.nirvanix.sdk.session;

class GetTags {
	public void callGetTags()  throws NirvanixException,
	                                         SDKException,
	                                         IOException {
		// Get the session
		Session session = new Session("ABCD-555443-APPKEY-DDEE44",
			"USERNAME",
			"PASSWORD",
			"APPNAME");
		// Get the files in /path/.
		ArrayList files = session.getFolder("/path/", 1, 
			500, folderSortCode.Name, true).getFiles();
		// Get all metadata for the first file in the file list.
		String[] tags = files.get(0).getTags();
	}
}
				

PHP Example (Zend SDK)

require_once $INCLUDEPATH . '/Zend/Service/Nirvanix.php'; 

// Get Session token for the user/password under the AppKey
$auth = array('username' => $username,'password' => $password,'appKey' => $appkey);

try{
	// This authenticates the user and retrieves session
	$nirvanix = new Zend_Service_Nirvanix($auth);
	// Get Metadata object.
	$metadata = $nirvanix->getService('Metadata');
	// get tags for /path/file.txt.
	$results = $metadata->GetTags(array('path' => '/path/file.txt'));
	print_r($results);
}catch (Zend_Service_Nirvanix_Exception $e) {
	$error = true;
}
				
back to top

SetTags

Sets tags for a single file or folder.

Reference Documentation

C# Example (FlatSDK)


public void callSetTags() {
	FlatSDK.Session session = new Session("ABCD-555443-APPKEY-DDEE44",
		"USERNAME",
		"PASSWORD");
	FlatSDK.Metadata metadata = new FlatSDK.Metadata(session);

	// sets the tags
	metadata.SetTags("/path/file.txt", new String[] { "sometag" });
}

				

Java Example


package com.nirvanix.sdk.session;

class SetMetadata {
	public void callSetAllMetadata()  throws NirvanixException,
	                                         SDKException,
	                                         IOException {
		// Get the session
		Session session = new Session("ABCD-555443-APPKEY-DDEE44",
			"USERNAME",
			"PASSWORD",
			"APPNAME");
		// Get the files in /path/.
		ArrayList files = session.getFolder("/path/", 1, 
			500, folderSortCode.Name, true).getFiles();
		
		// Set tags for the first file in the file list.
		String[] tagsToSet = { "sometag1", "sometag2" };
		files.get(0).setTags(tagsToSet);
	}
}
				

PHP Example (Zend SDK)

require_once $INCLUDEPATH . '/Zend/Service/Nirvanix.php'; 

// Get Session token for the user/password under the AppKey
$auth = array('username' => $username,'password' => $password,'appKey' => $appkey);

try{
	// This authenticates the user and retrieves session
	$nirvanix = new Zend_Service_Nirvanix($auth);
	// Get Metadata object.
	$metadata = $nirvanix->getService('Metadata');
	// set tags for /path/file.txt.
	$metadata->SetTags(array('path' => '/path/file.txt', 'tag' => 'sometag'));
}catch (Zend_Service_Nirvanix_Exception $e) {
	$error = true;
}
				
back to top

SearchMetadata

Searches all files and folders for Metadata that matches the criteria.

Reference Documentation

C# Example (FlatSDK)


public void callSearchMetadata() {
	FlatSDK.Session session = new Session("ABCD-555443-APPKEY-DDEE44",
		"USERNAME",
		"PASSWORD");
	FlatSDK.Metadata metadata = new FlatSDK.Metadata(session);

	// sets the tags
	SearchResults results = metadata.SearchMetadata("USERNAME",
			"somekey",
			"somevalue",
			10000);
}

				

Java Example


package com.nirvanix.sdk.session;

class SearchMetadata {
	public void callSearchMetadata()  throws NirvanixException,
	                                         SDKException,
	                                         IOException {
		// Get the session
		Session session = new Session("ABCD-555443-APPKEY-DDEE44",
			"USERNAME",
			"PASSWORD",
			"APPNAME");
		
		SearchResults results = session.SearchMetadata("somekey", "somevalue", 10000);
	}
}
				

PHP Example (Zend SDK)

require_once $INCLUDEPATH . '/Zend/Service/Nirvanix.php'; 

// Get Session token for the user/password under the AppKey
$auth = array('username' => $username,'password' => $password,'appKey' => $appkey);

try{
	// This authenticates the user and retrieves session
	$nirvanix = new Zend_Service_Nirvanix($auth);
	// Get Metadata object.
	$metadata = $nirvanix->getService('Metadata');
	// Search metadata
	$results = $metadata->SearchMetadata(array('username' => $username, 
		'searchkey' => 'somekey', 
		'searchterm' => 'someterm', 
		'maxresults' => '10000'));
	print_r($results);
}catch (Zend_Service_Nirvanix_Exception $e) {
	$error = true;
}
				
back to top

SearchTags

Searches all files and folders for tags that match the criteria.

Reference Documentation

C# Example (FlatSDK)


public void callSearchTags() {
	FlatSDK.Session session = new Session("ABCD-555443-APPKEY-DDEE44",
		"USERNAME",
		"PASSWORD");
	FlatSDK.Metadata metadata = new FlatSDK.Metadata(session);

	// sets the tags
	SearchResults results = metadata.SearchTags("USERNAME",
			"somevalue",
			10000);
}

				

Java Example


package com.nirvanix.sdk.session;

class SearchTags {
	public void callSearchTags()  throws NirvanixException,
	                                         SDKException,
	                                         IOException {
		// Get the session
		Session session = new Session("ABCD-555443-APPKEY-DDEE44",
			"USERNAME",
			"PASSWORD",
			"APPNAME");
		
		SearchResults results = session.SearchTags("somevalue", 10000);
	}
}
				

PHP Example (Zend SDK)

require_once $INCLUDEPATH . '/Zend/Service/Nirvanix.php'; 

// Get Session token for the user/password under the AppKey
$auth = array('username' => $username,'password' => $password,'appKey' => $appkey);

try{
	// This authenticates the user and retrieves session
	$nirvanix = new Zend_Service_Nirvanix($auth);
	// Get Metadata object.
	$metadata = $nirvanix->getService('Metadata');
	// Search metadata
	$results = $metadata->SearchTags(array('username' => $username, 
		'searchterm' => 'someterm', 
		'maxresults' => '10000'));
	print_r($results);
}catch (Zend_Service_Nirvanix_Exception $e) {
	$error = true;
}
				
back to top

Sharing Namespace

The Sharing namespace is used to host files for public download.

ListHostedItems

Lists all publicly hosted items under an account.

Reference Documentation

C# Example (FlatSDK)

public void callListHostedItems() {
	FlatSDK.Session session = new Session("ABCD-555443-APPKEY-DDEE44",
		"USERNAME",
		"PASSWORD");
	FlatSDK.Sharing sharing = new FlatSDK.Sharing(session);
    // List all hosted items by page, page size
	sharing.ListHostedItems(1, 500);
}
				

Java Example

package com.nirvanix.sdk.session;

class ListHostedItems {
	public void callListHostedItems()  throws NirvanixException,
	                                         SDKException,
	                                         IOException {
		// Get the session
		Session session = new Session("ABCD-555443-APPKEY-DDEE44",
			"USERNAME",
			"PASSWORD",
			"APPNAME");
		
		HostedItem[] items = session.listHostedItems(1, 500);
	}
}
				

PHP Example (Zend SDK)

require_once $INCLUDEPATH . '/Zend/Service/Nirvanix.php'; 

// Get Session token for the user/password under the AppKey
$auth = array('username' => $username,'password' => $password,'appKey' => $appkey);

try{
	// This authenticates the user and retrieves session
	$nirvanix = new Zend_Service_Nirvanix($auth);
	// Get sharing object.
	$sharing = $nirvanix->getService('Sharing');
	// Get a list of the hosted items
	$results = $sharing->ListHostedItems(array('pageNumber' => '1', 'pageSize' => '500'));
	print_r($results);
}catch (Zend_Service_Nirvanix_Exception $e) {
	$error = true;
}
				
back to top

CreateHostedItem

Makes a file or folder available for public download.

Reference Documentation

C# Example (FlatSDK)

public void callCreateHostedItem() {
	FlatSDK.Session session = new Session("ABCD-555443-APPKEY-DDEE44",
		"USERNAME",
		"PASSWORD");
	FlatSDK.IMFS imfs = new FlatSDK.IMFS(session);
	string[] newFolders = {"/newSrcPath/"}
	imfs.CreateFolders(newFolders);
	FlatSDK.Sharing sharing = new FlatSDK.Sharing(session);
    // Create a new hosted item from the folder.
	sharing.CreateHostedItem("/newSrcPath/");
}
				

Java Example

package com.nirvanix.sdk.session;

class CreateHostedItem {
	public void callCreateHostedItem()  throws NirvanixException,
	                                         SDKException,
	                                         IOException {
		// Get the session
		Session session = new Session("ABCD-555443-APPKEY-DDEE44",
			"USERNAME",
			"PASSWORD",
			"APPNAME");
		// Get the files in /path/.
		ArrayList files = session.getFolder("/path/", 1, 
			500, folderSortCode.Name, true).getFiles();
		// Host the first file in the file list.
		files.get(0).HostItem();
	}
}
				

PHP Example (Zend SDK)

require_once $INCLUDEPATH . '/Zend/Service/Nirvanix.php'; 

// Get Session token for the user/password under the AppKey
$auth = array('username' => $username,'password' => $password,'appKey' => $appkey);

try{
	// This authenticates the user and retrieves session
	$nirvanix = new Zend_Service_Nirvanix($auth);
	// Get sharing object.
	$sharing = $nirvanix->getService('Sharing');
	// Create a new hosted item
	$sharing->CreateHostedItem(array('sharePath' => '/pathtoshare/'));
}catch (Zend_Service_Nirvanix_Exception $e) {
	$error = true;
}
				
back to top

RemoveHostedItem

Removes a file or folder from the list for public download.

Reference Documentation

C# Example (FlatSDK)

public void callRemoveHostedItem() {
	FlatSDK.Session session = new Session("ABCD-555443-APPKEY-DDEE44",
		"USERNAME",
		"PASSWORD");
	FlatSDK.IMFS imfs = new FlatSDK.IMFS(session);
	FlatSDK.Sharing sharing = new FlatSDK.Sharing(session);
    // Unshares the folder.
	sharing.RemoveHostedItem("/newSrcPath/");
}
				

Java Example

package com.nirvanix.sdk.session;

class RemoveHostedItem {
	public void callRemoveHostedItem()  throws NirvanixException,
	                                         SDKException,
	                                         IOException {
		// Get the session
		Session session = new Session("ABCD-555443-APPKEY-DDEE44",
			"USERNAME",
			"PASSWORD",
			"APPNAME");
		// Get the files in /path/.
		ArrayList files = session.getFolder("/path/", 1, 
			500, folderSortCode.Name, true).getFiles();
		// Unshare the first file in the file list.
		files.get(0).RemoveHostedItem();
	}
}
				

PHP Example (Zend SDK)

require_once $INCLUDEPATH . '/Zend/Service/Nirvanix.php'; 

// Get Session token for the user/password under the AppKey
$auth = array('username' => $username,'password' => $password,'appKey' => $appkey);

try{
	// This authenticates the user and retrieves session
	$nirvanix = new Zend_Service_Nirvanix($auth);
	// Get sharing object.
	$sharing = $nirvanix->getService('Sharing');
	// Unshares a hosted item
	$sharing->RemoveHostedItem(array('sharePath' => '/pathtoshare/'));
}catch (Zend_Service_Nirvanix_Exception $e) {
	$error = true;
}
				
back to top

Video Namespace

The Video namespace allows sound format conversion through transcode and frame extraction.

PresetTranscode

Converts a video file from one format to another creating a new file. The results are returned in a callback.

Reference Documentation

C# Example (FlatSDK)

public void callVideoPresetTranscode() {
	FlatSDK.Session session = new Session("ABCD-555443-APPKEY-DDEE44",
		"USERNAME",
		"PASSWORD");
	FlatSDK.Video video = new FlatSDK.Video(session);
    // Convert a video file
	video.PresetTranscode("/sourceFilePath/vid.mov",
			"/destFilePath/vid.flv",
			TranscodePreset.H263_FLV_Medium,
			-1,
			-1,
			"http://www.yoursite.com/callbackhandler");
}
				

Java Example

package com.nirvanix.sdk.session;

class VideoPresetTranscode {
	public void callPresetTranscode()  throws NirvanixException,
	                                         SDKException,
	                                         IOException {
		// Get the session
		Session session = new Session("ABCD-555443-APPKEY-DDEE44",
			"USERNAME",
			"PASSWORD",
			"APPNAME");
		// Get the files in /path/.
		ArrayList files = session.getFolder("/path/", 1, 
		      500, folderSortCode.Name, true).getFiles();
		// PresetTranscode Video file.
 		files.get(0).PresetTranscodeVideo("/destFilePath/vid.flv",
            null,
            TranscodePresets.H264_FLV_Medium,
            "http://www.yoursite.com/callbackhandler");
	}
}
				

PHP Example (Zend SDK)

require_once $INCLUDEPATH . '/Zend/Service/Nirvanix.php'; 

// Get Session token for the user/password under the AppKey
$auth = array('username' => $username,'password' => $password,'appKey' => $appkey);

try{
	// This authenticates the user and retrieves session
	$nirvanix = new Zend_Service_Nirvanix($auth);
	// Get video object.
	$video = $nirvanix->getService('Video');
	$videoPresetTranscodeParams = array('srcFilePath' => '/sourcepath/vid.mov",
			'destFilePath' => '/destpath/vid.flv",
			'preset' => 'H264 FLV Medium',
			'callbackURL' => 'http://www.yoursite.com/callbackhandler.php');
	// Video Transcode file
	$video->PresetTranscode($videoPresetTranscodeParams);
}catch (Zend_Service_Nirvanix_Exception $e) {
	$error = true;
}
				
back to top

Transcode

Converts a video file from one format to another creating a new file. The results are returned in a callback.

Reference Documentation

C# Example (FlatSDK)

public void callVideoTranscode() {
	FlatSDK.Session session = new Session("ABCD-555443-APPKEY-DDEE44",
		"USERNAME",
		"PASSWORD");
	FlatSDK.Video video = new FlatSDK.Video(session);
    // Convert a video file
	video.Transcode("/sourceFilePath/vid.mov",
			null,
			"/destFilePath/vid.flv",
			VideoTranscodingFormat.FLV,
			"http://www.yoursite.com/callbackhandler");
}
				

Java Example

package com.nirvanix.sdk.session;

class VideoTranscode {
	public void callTranscode()  throws NirvanixException,
	                                         SDKException,
	                                         IOException {
		// Get the session
		Session session = new Session("ABCD-555443-APPKEY-DDEE44",
			"USERNAME",
			"PASSWORD",
			"APPNAME");
		// Get the files in /path/.
		ArrayList files = session.getFolder("/path/", 1, 
		      500, folderSortCode.Name, true).getFiles();
		// Transcode Video file.
		String newFileName = "/destFilePath/vid.flv";
        VideoTranscodingOptions[] options = null;
        TranscodingFormat targetFormat = TranscodingFormat.FLV;
        String callbackURL = "http://www.yoursite.com/callbackhandler";
        
        files.get(0).TranscodeVideo(newFileName, options, targetFormat, callbackURL);
	}
}
				

PHP Example (Zend SDK)

require_once $INCLUDEPATH . '/Zend/Service/Nirvanix.php'; 

// Get Session token for the user/password under the AppKey
$auth = array('username' => $username,'password' => $password,'appKey' => $appkey);

try{
	// This authenticates the user and retrieves session
	$nirvanix = new Zend_Service_Nirvanix($auth);
	// Get Video object.
	$video = $nirvanix->getService('Video');
	$videoTranscodeParams = array('srcFilePath' => '/sourcepath/vid.mov",
			'destFilePath' => '/destpath/vid.flv",
			'callbackURL' => 'http://www.yoursite.com/callbackhandler.php');
	// Video Transcode file
	$video->Transcode($videoTranscodeParams);
}catch (Zend_Service_Nirvanix_Exception $e) {
	$error = true;
}
				
back to top

ExtractFrames

Converts a video file from one format to another creating a new file. The results are returned in a callback.

Reference Documentation

C# Example (FlatSDK)

public void callVideoExtractFrames() {
	FlatSDK.Session session = new Session("ABCD-555443-APPKEY-DDEE44",
		"USERNAME",
		"PASSWORD");
	FlatSDK.Video video = new FlatSDK.Video(session);
    // Extract a frame from the video.
	video.ExtractFrames("/sourceFilePath/vid.mov",
			"/destFrameFolder/",
			"1",
			1,
			"640",
			"480",
			"5",
			"FirstFrame",
			FrameExtractionFormat.JPG,
			"1",
			"http://www.yoursite.com/callbackhandler");
}
				

PHP Example (Zend SDK)

require_once $INCLUDEPATH . '/Zend/Service/Nirvanix.php'; 

// Get Session token for the user/password under the AppKey
$auth = array('username' => $username,'password' => $password,'appKey' => $appkey);

try{
	// This authenticates the user and retrieves session
	$nirvanix = new Zend_Service_Nirvanix($auth);
	// Get video object.
	$video = $nirvanix->getService('Video');
	$extractFramesParams = array('srcFilePath' => '/sourcepath/vid.mov',
			'destFolderPath' => '/destFramePath/',
			'numberOfFrames' => '1',
			'frameName' => 'FirstFrame',
			'startTimeOffset' => '5',
			'callbackURL' => 'http://www.yoursite.com/callbackhandler.php');
	// Extract a frame from a video
	$video->ExtractFrames($extractFramesParams);
}catch (Zend_Service_Nirvanix_Exception $e) {
	$error = true;
}
				
back to top