App42 Cloud API

Ruby Cloud SDK

File Storage

In order to use the various functions available under a particular API, a developer will have to create an instance of ServiceAPI by passing the apiKey and the secretKey which has been received while creating an app.

	api = App42::ServiceAPI.new("<API_KEY>","<SECRET_KEY>")  

After initialization, developer needs to call the buildXXXService method on ServiceAPI instance to get the instance of the particular API that you wish to build. For example, To build an instance of UploadService, buildUploadService() method needs to be called.

	UploadService upload = api.buildUploadService();

Once the API instance has been retrieved, You are ready to use the functions available for that particular API.

The methods available under a particular API will return the domain object (like Upload in this case) as a response which will have the accessor / mutator to access the available properties for that object. You can get the response in the form of JSON as well. We have provided the JSON response with every function detail which can be retrieved by calling the toString() on the returned object.

name = "TextFile007";
filePath = "Local file path";
fType = App42::Upload::UploadFileType.new();
uploadFileType = fType.enum("IMAGE");
description = "TextFile_123";
						
upload = uploadService.upload_file(fileName, filePath, fileType, description); /* returns the Upload object. */
fileList = Array.new();
fileList =  upload.fileList();
for file in fileList do
  puts "fileName is #{file.name}";
  puts "fileType is #{file.type}";
  puts "url is #{file.url}";
  puts "description is #{file.description}";
end
jsonResponse = upload.to_s(); /* returns the response in JSON format. */ 

The functions available under File Upload API can throw some exceptions in abnormal conditions. Example of the same has been given below.

E.g. If App developer is requesting for the files by type which is not in database, the function will throw the App42Exception (as shown below) with message as "Not Found" and the appErrorCode as "2102" and the details as "Files for the user <userName> do not exist.".

userName = "Nick";
						
begin
  upload = uploadService.get_all_files_by_user(userName);
rescue App42Exception => ex
  appErrorCode = ex.app_error_code;
  httpErrorCode = ex.http_error_code;

  if(appErrorCode == 2102)
    #Handle here for Not found (Files for the user <userName> do not exist.)

  elsif(appErrorCode == 1401)
    #handle here for Client is not authorized

  else(appErrorCode == 1500)
    #handle here for Internal Server Error
  end

  jsonText = ex.getMessage(); /* returns the Exception text in JSON format. (as shown below)*/
end 
	{
		"app42Fault": {
			"httpErrorCode": 404,
			"appErrorCode": 2102,
			"message": "BAD REQUEST",
			"details": "Files for the user 'Nick' do not exist."
		}
	}	

Below are the HTTP Error Codes and their description, the function under the File Upload API can throw.

/*
1400 - BAD REQUEST - The Request parameters are invalid
1401 - UNAUTHORIZED - Client is not authorized
1500 - INTERNAL SERVER ERROR - Internal Server Error. Please try again	
*/	

Below are the Application Error Codes and their description, the function under the File Upload API can throw.

/*
2100 - BAD REQUEST - The request parameters are invalid. File by the name <name> already exists.
2101 - NOT FOUND - Files do not exist. 
2102 - NOT FOUND - Files for the user <userName> do not exist.
2103 - NOT FOUND - The file with the name <name> does not exist.
2104 - NOT FOUND - There are no files to remove.
2105 - NOT FOUND - The file with type <type> does not exist. 
2106 - NOT FOUND - The number of files are less than the specified offset : '<offset>'.
2107 - NOT FOUND - The number of files for the user <userName> are less than the specified offset : '<offset>'.
2108 - NOT FOUND - The number of files with type <type> are less than the specified offset : '<offset>'.
*/	

Various functions available under File Upload API has been explained below.

def upload_file(name, filePath, fileType, description)

Uploads file on the cloud.

Parameters:

name - The name for the file which has to be saved. It is used to retrieve the file
filePath - The local path for the file
fileType - The type of the file. File can be either Audio, Video, Image, Binary, Txt, xml, json, csv or other Use the static constants e.g. Upload.AUDIO, Upload.XML etc.
description - Description of the file to be uploaded.

Returns:

Upload object

Response: Upload Object

Exception:

The method throws the following exception with the error code
/*
2100 - BAD REQUEST - The request parameters are invalid. File by the name <name> already exists.
*/  		  
        
For more details click Exception
name = "TextFile007";
filePath = "Local file path";
fType = App42::Upload::UploadFileType.new();
uploadFileType = fType.enum("IMAGE");
description = "TextFile_123";
						
upload = uploadService.upload_file(fileName,filePath,fileType,description); /* returns the Upload object. */
fileList = Array.new();
for file in fileList do
  puts "fileName is #{file.name}";
  puts "fileType is #{file.type}";
  puts "url is #{file.url}";
  puts "description is #{file.description}";
end
jsonResponse = upload.to_s(); /* returns the response in JSON format. (as shown below)*/  
{
    "app42": {
        "response": {
            "success": true,
            "upload": {
                "files": {
                    "file": {
                        "name": "TextFile007",
                        "type": "TXT",
                        "url": "http://XXXX.txt",
                        "tinyUrl": "http://tinyurl.com/XXXX",
                        "description": "TextFile_123"
                    }
                }
            }
        }
    }
} 
def get_all_files()

Gets all the files for the App.

Parameters:

N/A

Returns:

Upload object

Response: Upload Object

Exception:

The method throws the following exception with the error code
/*
2101 - NOT FOUND - Files do not exist.  
*/   
For more details click Exception
upload = uploadService.get_all_files(); /* returns the Upload object. */
fileList = Array.new();
for file in fileList do
  puts "fileName is #{file.name}";
  puts "fileType is #{file.type}";
  puts "url is #{file.url}";
  puts "description is #{file.description}";
end
jsonResponse = upload.to_s(); /* returns the response in JSON format. (as shown below)*/ 
{
    "app42": {
        "response": {
            "success": true,
            "upload": {
                "files": {
                    "file": [
                        {
                            "name": "TextFile01",
                            "type": "TXT",
                            "url": "http://XXXX.txt",
							"tinyUrl": "http://tinyurl.com/XXXX",
                            "description": "TextFile_123"
                        },
                        {
                            "name": "TextFile007",
                            "type": "TXT",
                            "url": "http://XXXX.txt",
							"tinyUrl": "http://tinyurl.com/XXXX",
                            "description": "TextFile_123"
                        }
                    ]
                }
            }
        }
    }
} 
def get_all_files_count()

Gets count of all the files for the App

Parameters:

N/A

Returns:

App42Response object

Response: App42Response Object

For more details click Exception
response = uploadService.get_all_files_count(); /* returns the App42Response objects. */
success = response.isResponseSuccess();
totalRecords = response.totalRecords();
jsonResponse = response.to_s(); /* returns the response in JSON format. (as shown below)*/ 
{
    "app42": {
        "response": {
            "success": true,
            "totalRecords": 3
        }
    }
} 
def get_all_files_by_paging(max, offset)

Gets all the files By Paging for the App.

Parameters:

max - Maximum number of records to be fetched
offset - From where the records are to be fetched

Returns:

Upload object

Response: Upload Object

Exception:

The method throws the following exception with the error code
/*
2106 - NOT FOUND - The number of files are less than the specified offset : <offset>.
*/      
For more details click Exception
max = 1;
offset = 0;	
					
upload = uploadService.get_all_files_by_paging(max, offset); /* returns the Upload object. */
fileList = Array.new();
for file in fileList do
  puts "fileName is #{file.name}";
  puts "fileType is #{file.type}";
  puts "url is #{file.url}";
  puts "description is #{file.description}";
end
jsonResponse = upload.to_s(); /* returns the response in JSON format. (as shown below)*/ 
{
    "app42": {
        "response": {
            "success": true,
            "upload": {
                "files": {
                    "file": {
                        "name": "FILEName123",
                        "userName": "Nick",
                        "type": "AUDIO",
                        "url": "http://XXXX.mp3",
						"tinyUrl": "http://tinyurl.com/XXXX",
                        "description": "desc"
                    }
                }
            }
        }
    }
}
def get_file_by_name(name)

Gets the file based on file name.

Parameters:

name - The name of the file which has to be retrieved

Returns:

Upload object

Response: Upload Object

Exception:

The method throws the following exception with the error code
/*
2103 - NOT FOUND - The file with the name <name> does not exist.  
*/ 
For more details click Exception
name = "TextFile01";
						
upload = uploadService.get_file_by_name(name); /* returns the Upload object. */
fileList = Array.new();
for file in fileList do
  puts "fileName is #{file.name}";
  puts "fileType is #{file.type}";
  puts "url is #{file.url}";
  puts "description is #{file.description}";
end
jsonResponse = upload.to_s(); /* returns the response in JSON format. (as shown below)*/
{
    "app42": {
        "response": {
            "success": true,
            "upload": {
                "files": {
                    "file": {
                        "name": "TextFile01",
                        "type": "TXT",
                        "url": "http://XXXX.txt",
						"tinyUrl": "http://tinyurl.com/XXXX",
                        "description": "TextFile_123"
                    }
                }
            }
        }
    }
}
def get_files_by_type(uploadFileType)

Get the files based on file type.

Parameters:

uploadFileType - Type of the file e.g. Upload.AUDIO, Upload.XML etc.

Returns:

Upload object

Response: Upload Object

Exception:

The method throws the following exception with the error code
/*
2105 - NOT FOUND - The file with type <type> does not exist.
*/ 
For more details click Exception
fType = App42::Upload::UploadFileType.new();
uploadFileType = fType.enum("IMAGE");
						
upload = uploadService.get_files_by_type(uploadFileType); /* returns the Upload object. */
fileList = Array.new();
for file in fileList do
  puts "fileName is #{file.name}";
  puts "fileType is #{file.type}";
  puts "url is #{file.url}";
  puts "description is #{file.description}";
end
jsonResponse = upload.to_s(); /* returns the response in JSON format. (as shown below)*/ 
{
    "app42": {
        "response": {
            "success": true,
            "upload": {
                "files": {
                    "file": [
                        {
                            "name": "TextFile01",
                            "type": "TXT",
                            "url": "http://XXXX.txt",
                            "tinyUrl": "http://tinyurl.com/XXXX",
                            "description": "TextFile_123"
                        },
                        {
                            "name": "TextFile007",
                            "type": "TXT",
                            "url": "http://XXXX.txt",
                            "tinyUrl": "http://tinyurl.com/XXXX",
                            "description": "TextFile_123"
                        }
                    ]
                }
            }
        }
    }
}
def get_files_count_by_type(uploadFileType)

Get the count of files based on file type.

Parameters:

uploadFileType - Type of the file e.g. Upload.AUDIO, Upload.XML etc.

Returns:

App42Response object

Response: App42Response Object

For more details click Exception
fType = App42::Upload::UploadFileType.new();
uploadFileType = fType.enum("IMAGE");
						
response = uploadService.get_files_count_by_type(uploadFileType); /* returns the App42Response objects. */
success = response.isResponseSuccess();
totalRecords = response.totalRecords();
jsonResponse = response.to_s(); /* returns the response in JSON format. (as shown below)*/ 
{
    "app42": {
        "response": {
            "success": true,
            "totalRecords": 3
        }
    }
}
def get_files_by_type_by_paging(uploadFileType, max, offset)

Get the files based on file type by Paging.

Parameters:

uploadFileType - Type of the file e.g. Upload.AUDIO, Upload.XML etc.
max - Maximum number of records to be fetched
offset - From where the records are to be fetched

Returns:

Upload object

Response: Upload Object

Exception:

The method throws the following exception with the error code
/*
2108 - NOT FOUND - The number of files with type <type> are less than the specified offset : '<offset>'. 
*/   
For more details click Exception
fType = App42::Upload::UploadFileType.new();
uploadFileType = fType.enum("IMAGE");						
max = 1;
offset = 0;
						
upload = uploadService.get_files_by_type_by_paging(uploadFileType, max, offset); /* returns the Upload object. */
fileList = Array.new();
for file in fileList do
  puts "fileName is #{file.name}";
  puts "fileType is #{file.type}";
  puts "url is #{file.url}";
  puts "description is #{file.description}";
end
jsonResponse = upload.to_s(); /* returns the response in JSON format. (as shown below)*/
{
    "app42": {
        "response": {
            "success": true,
            "upload": {
                "files": {
                    "file": {
                        "name": "FILEName123",
                        "userName": "Nick",
                        "type": "AUDIO",
                        "url": "http://XXXX.mp3",
                        "tinyUrl": "http://tinyurl.com/XXXX",
                        "description": "desc"
                    }
                }
            }
        }
    }
}
def remove_file_by_name(name)

Removes the file based on file name.

Parameters:

name - The name of the file which has to be removed

Returns:

App42Response if deleted successfully

Response: App42Response Object

Exception:

The method throws the following exception with the error code
/*
2103 - NOT FOUND - The file with the name <name> does not exist.
*/  
For more details click Exception
name = "TextFile007";
						
response = uploadService.remove_file_by_name(name); /* returns the App42Response object. */
success = response.isResponseSuccess();
jsonResponse = response.to_s(); /* returns the response in JSON format. (as shown below)*/  
{
    "app42": {
        "response": {
            "success": true,
            "upload": {
                "files": {
                    "file": {
                        "name": "TextFile007",
                        "userName": "Nick",
                        "type": "TXT",
                        "url": "http://XXXX.txt",
                        "tinyUrl": "http://tinyurl.com/XXXX",
                        "description": "TextFile_098"
                    }
                }
            }
        }
    }
}
def remove_all_files()

Removes all the files for the App

Parameters:

N/A

Returns:

App42Response if deleted successfully

Response: App42Response Object

Exception:

The method throws the following exception with the error code
/*
2104 - NOT FOUND - There are no files to remove.
*/
For more details click Exception
response = uploadService.remove_all_files(); /* returns the App42Response object. */
success = response.isResponseSuccess();
jsonResponse = response.to_s(); /* returns the response in JSON format. (as shown below)*/
                            
{
    "app42": {
        "response": {
            "success": true,
            "upload": {
                "files": {
                    "file": [
                        {
                            "name": "FILEName01844",
                            "userName": "Nick",
                            "type": "AUDIO",
                            "url": "http://XXXX.mp3",
                            "tinyUrl": "http://tinyurl.com/XXXX",
                            "description": "Audio123"
                        },
                        {
                            "name": "FILEName01755",
                            "userName": "Nick",
                            "type": "AUDIO",
                            "url": "http://YYYY.mp3",
                            "tinyUrl": "http://tinyurl.com/XXXX",
                            "description": "Audio123"
                        }
                    ]
                }
            }
        }
    }
}
def upload_file_for_user(name, userName, filePath, fileType, description)

Uploads file on the cloud.

Parameters:

name - The name for the file which has to be saved. It is used to retrieve the file
userName - The name for the user for which file has to be saved.
filePath - The local path for the file
fileType - The type of the file. File can be either Audio, Video, Image, Binary, Txt, xml, json, csv or other Use the static constants e.g. Upload.AUDIO, Upload.XML etc.
description - Description of the file to be uploaded.

Returns:

Upload object

Response: Upload Object

Exception:

The method throws the following exception with the error code
/*
2100 - BAD REQUEST - The request parameters are invalid. File by the name <name> already exists.
*/ 
For more details click Exception
name = "File03";
userName = "Nick";
filePath = "Local file path";
fType = App42::Upload::UploadFileType.new();
uploadFileType = fType.enum("IMAGE");
description = "TextFile_098";
						
upload = uploadService.upload_file_for_user(name,userName,filePath,uploadFileType,description); /* returns the Upload object. */
fileList = Array.new();
for file in fileList do
  puts "fileName is #{file.name}";
  puts "fileType is #{file.type}";
  puts "url is #{file.url}";
  puts "description is #{file.description}";
end
jsonResponse = upload.to_s(); /* returns the response in JSON format. (as shown below)*/ 
{
    "app42": {
        "response": {
            "success": true,
            "upload": {
                "files": {
                    "file": {
                        "name": "File03",
                        "userName": "Nick",
                        "type": "TXT",
                        "url": "http://XXXX.txt",
                        "tinyUrl": "http://tinyurl.com/XXXX",
                        "description": "TextFile_098"
                    }
                }
            }
        }
    }
}
def get_file_by_user(name,userName)

Gets the file based on Username.

Parameters:

name - The name of the file which has to be retrieved
userName - The name of the user for which file has to be retrieved

Returns:

Upload object

Response: Upload Object

Exception:

The method throws the following exception with the error code
/*
2102 - NOT FOUND - Files for the user <userName> do not exist.
2103 - NOT FOUND - The file with the name <name> does not exist. 
*/ 	 
For more details click Exception
name = "File03";
userName = "Nick";
						
upload = uploadService.get_file_by_user(name,userName); /* returns the Upload object. */
fileList = Array.new();
for file in fileList do
  puts "fileName is #{file.name}";
  puts "fileType is #{file.type}";
  puts "url is #{file.url}";
  puts "description is #{file.description}";
end
jsonResponse = upload.to_s(); /* returns the response in JSON format. (as shown below)*/  
{
    "app42": {
        "response": {
            "success": true,
            "upload": {
                "files": {
                    "file": {
                        "name": "File03",
                        "userName": "Nick",
                        "type": "TXT",
                        "url": "http://XXXX.txt",
                        "description": "TextFile_098"
                    }
                }
            }
        }
    }
}
def get_all_files_by_user(userName)

Get all the files based on user name.

Parameters:

userName - The name of the user for which file has to be retrieved

Returns:

Upload object

Response: Upload Object

Exception:

The method throws the following exception with the error code
/*
2102 - NOT FOUND - Files for the user <userName> do not exist. 
*/ 
For more details click Exception
userName = "Nick";

upload = uploadService.get_all_files_by_user(userName); /* returns the Upload object. */
fileList = Array.new();
for file in fileList do
  puts "fileName is #{file.name}";
  puts "fileType is #{file.type}";
  puts "url is #{file.url}";
  puts "description is #{file.description}";
end
jsonResponse = upload.to_s(); /* returns the response in JSON format. (as shown below)*/
{
    "app42": {
        "response": {
            "success": true,
            "upload": {
                "files": {
                    "file": [
                        {
                            "name": "File02",
                            "userName": "Nick",
                            "type": "IMAGE",
                            "url": "http://XXXX.jpg",
                            "tinyUrl": "http://tinyurl.com/XXXX",
                            "description": "Image_012"
                        },
                        {
                            "name": "File03",
                            "userName": "Nick",
                            "type": "TXT",
                            "url": "http://XXXX.txt",
                            "tinyUrl": "http://tinyurl.com/XXXX",
                            "description": "TextFile_098"
                        }
                    ]
                }
            }
        }
    }
}
def get_all_files_count_by_user(userName)

Gets the count of file based on user name.

Parameters:

userName - The name of the user for which count of the file has to be retrieved

Returns:

App42Response object

Response: App42Response Object

For more details click Exception
userName = "Nick";
						
response = uploadService.get_all_files_count_by_user(userName); /* returns the App42Response objects. */
success = response.isResponseSuccess();
totalRecords = response.totalRecords();
jsonResponse = response.to_s(); /* returns the response in JSON format. (as shown below)*/ 
{
    "app42": {
        "response": {
            "success": true,
            "totalRecords": 3
        }
    }
}
def get_all_files_by_user_by_paging(userName, max, offset)

Gets the file based on user name by Paging.

Parameters:

userName - The name of the user for which file has to be retrieved
max - Maximum number of records to be fetched
offset - From where the records are to be fetched

Returns:

Upload object

Response: Upload Object

Exception:

The method throws the following exception with the error code
/*
2107 - NOT FOUND - The number of files for the user <userName> are less than the specified offset : '<offset>'. 
*/  
For more details click Exception
userName = "Nick";
max = 1;
offset = 0;
						
upload = uploadService.get_all_files_by_user_by_paging(userName, max, offset); /* returns the Upload object. */
fileList = Array.new();
for file in fileList do
  puts "fileName is #{file.name}";
  puts "fileType is #{file.type}";
  puts "url is #{file.url}";
  puts "description is #{file.description}";
end
jsonResponse = upload.to_s(); /* returns the response in JSON format. (as shown below)*/  
{
    "app42": {
        "response": {
            "success": true,
            "upload": {
                "files": {
                    "file": {
                        "name": "FileName11",
                        "userName": "Nick",
                        "type": "IMAGE",
                        "url": "http://XXXX.jpg",
                        "tinyUrl": "http://tinyurl.com/XXXX",
                        "description": "Image123"
                    }
                }
            }
        }
    }
}
def remove_file_by_user(name, userName)

Removes the file based on file name and user name.

Parameters:

name - The name of the file which has to be removed
userName - The name of the user for which file has to be removed

Returns:

App42Response if deleted successfully

Response: App42Response Object

Exception:

The method throws the following exception with the error code
/*
2102 - NOT FOUND - Files for the user <userName> do not exist.
2103 - NOT FOUND - The file with the name <name> does not exist.  
*/ 
For more details click Exception
name = "File03";
userName = "Nick";
						
response = uploadService.remove_file_by_user(name, userName); /* returns the App42Response object. */
success = response.isResponseSuccess();
jsonResponse = response.to_s(); /* returns the response in JSON format. (as shown below)*/    
{
    "app42": {
        "response": {
            "success": true,
            "upload": {
                "files": {
                    "file": {
                        "name": "File03",
                        "userName": "Nick",
                        "type": "TXT",
                        "url": "http://XXXX.txt",
                        "tinyUrl": "http://tinyurl.com/XXXX",
                        "description": "TextFile_098"
                    }
                }
            }
        }
    }
} 
def remove_all_files_by_user(userName)

Removes the file based on user name.

Parameters:

userName - The name of the user for which file has to be removed

Returns:

App42Response if deleted successfully

Response: App42Response Object

Exception:

The method throws the following exception with the error code
/*
2102 - NOT FOUND - Files for the user <userName> do not exist. 
*/ 	  
For more details click Exception
userName = "Nick";
						
response = uploadService.remove_all_files_by_user(userName); /* returns the App42Response object. */
success = response.isResponseSuccess();
jsonResponse = response.to_s(); /* returns the response in JSON format. (as shown below)*/  
{
    "app42": {
        "response": {
            "success": true,
            "upload": {
                "files": {
                    "file": [
                        {
                            "name": "File02",
                            "userName": "Nick",
                            "type": "TXT",
                            "url": "http://XXXX.txt",
							"tinyUrl": "http://tinyurl.com/XXXX",
                            "description": "Image_012"
                        },
                        {
                            "name": "File03",
                            "userName": "Billy",
                            "type": "TXT",
                            "url": "http://XXXX.txt",
							"tinyUrl": "http://tinyurl.com/XXXX",
                            "description": "Image_013"
                        }
                    ]
                }
            }
        }
    }
}
def upload_file_by_stream(name, inputStream, fileType, description)

Uploads file via stream on the cloud.

Parameters:

name - The name for the file which has to be saved. It is used to retrieve the file
inputStream - Input Stream for the Photo that has to be added
fileType - The type of the file. File can be either Audio, Video, Image, Binary, Txt, xml, json, csv or other Use the static constants e.g. Upload.AUDIO, Upload.XML etc.
description - Description of the file to be uploaded.

Returns:

Upload object

Response: Upload Object

For more details click Exception
name = "TextFile007";
inputStream = File.open('localPath', 'r');
fType = App42::Upload::UploadFileType.new();
fileType = fType.enum("IMAGE");
description = "TextFile_123";
						
upload = uploadService.upload_file_by_stream(name, inputStream, fileType, description); /* returns the Upload object. */
fileList = Array.new();
for file in fileList do
  puts "fileName is #{file.name}";
  puts "fileType is #{file.type}";
  puts "url is #{file.url}";
  puts "description is #{file.description}";
end
jsonResponse = upload.to_s(); /* returns the response in JSON format. (as shown below)*/
{
    "app42": {
        "response": {
            "success": true,
            "upload": {
                "files": {
                    "file": {
                        "name": "TextFile007",
                        "type": "TXT",
                        "url": "http://XXXX.txt",
                        "tinyUrl": "http://tinyurl.com/XXXX",
                        "description": "TextFile_123"
                    }
                }
            }
        }
    }
}
def upload_file_for_user_by_stream(name, userName, inputStream, fileType, description)

Uploads file via stream on the cloud.

Parameters:

name - The name for the file which has to be saved. It is used to retrieve the file
userName - The name for the user for which file has to be saved.
inputStream - Input Stream for the Photo that has to be added
fileType - The type of the file. File can be either Audio, Video, Image, Binary, Txt, xml, json, csv or other Use the static constants e.g. Upload.AUDIO, Upload.XML etc.
description - Description of the file to be uploaded.

Returns:

Upload object

Response: Upload Object

For more details click Exception
name = "TextFile007";
inputStream = File.open('localPath', 'r');
fType = nil;
fType = App42::Upload::UploadFileType.new();
uploadFileType = fType.enum("IMAGE");
description = "TextFile_123";
						
upload = uploadService.upload_file_for_user_by_stream(name, userName, inputStream, uploadFileType, description); /* returns the Upload object. */
fileList = Array.new();
for file in fileList do
  puts "fileName is #{file.name}";
  puts "fileType is #{file.type}";
  puts "url is #{file.url}";
  puts "description is #{file.description}";
end
jsonResponse = upload.to_s(); /* returns the response in JSON format. (as shown below)*/
{
    "app42": {
        "response": {
            "success": true,
            "upload": {
                "files": {
                    "file": {
                        "name": "TextFile007",
                        "type": "TXT",
                        "url": "http://XXXX.txt",
                        "tinyUrl": "http://tinyurl.com/XXXX",
                        "description": "TextFile_123"
                    }
                }
            }
        }
    }
}