App42 Cloud API

Windows Phone 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.

	
ServiceAPI api = new ServiceAPI("<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 uploadService = api.BuildUploadService();

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

The Windows Phone API's work in an asynchronous mode that means the response will not be available immediately and all the API methods would not return any value and have return type as void. The response will be returned in callback methods which the caller will provide to the calling method.
As mentioned above that the response will be returned in callback methods, every API method is taking instance of App42Callback (as the last parameter) which will have the implementation of 2 methods: OnSuccess & OnException.(as shown below)

public class CallBack : App42Callback
{
public override void OnSuccess(Object obj)
{
Upload upload = (Upload) obj;
//Do whatever you want with the user object
}
public override void OnException(App42Exception e)
{
//Do whatever you want with the exception
}
}

The callback methods will return the response in the form of Object which will have to be type cast to the object domain object (e.g. App42Response / Upload in this case) The Domain object 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.

public override void OnSuccess(Object obj)
{
Upload upload = (Upload) obj;  
IList<Upload.File> fileList =  upload.GetFileList();  
for(int i=0;i < fileList.Count;i++){
Console.WriteLine("File Name is " + file.GetName());
Console.WriteLine("File Type is " + file.GetType());
Console.WriteLine("File Url is " + file.GetUrl());
Console.WriteLine("File Description is " + file.GetDescription());  
}
String jsonResponse = fileList.ToString(); /* 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.".

public override void OnException(App42Exception ex)
{
int appErrorCode = ex.GetAppErrorCode();
int httpErrorCode = ex.GetHttpErrorCode();
String jsonText = ex.GetMessage(); /* returns the Exception text in JSON format. (as shown below)*/	
}
	{
		"app42Fault": {
			"httpErrorCode": 404,
			"appErrorCode": 2102,
			"message": "Not Found",
			"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.

public void UploadFile(String name, Stream stream, String fileType, String description, App42Callback requestCallback)

Uploads file on the cloud.

Parameters:

name - The name for the file which has to be saved. It is used to retrieve the file
stream - The sequence of bytes 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.
requestCallback - Callback instance that will have the implementation of OnSuccess & OnException of App42Callback.

Returns:

Upload object

Response: Upload Object

Exception:

This method throws following exception.
/*
2100 - BAD REQUEST - The request parameters are invalid. File by the name '<name>' already exists.
*/ 	        
For more details click Exception
String name = "TextFile007";
Stream stream = "stream of file	";
String fileType = UploadFileType.IMAGE;
String description = "TextFile_123";

uploadService.UploadFile(name,stream,fileType,description,requestCallback); /* returns the Upload object. */  
OnSuccess(Object obj){
Upload upload = (Upload) obj;  
IList<Upload.File> fileList =  upload.GetFileList(); /* returns the upload file list. */
for (int i = 0; i < fileList.Count; i++)
{
Console.WriteLine("File Name is " + fileList[i].GetName());
Console.WriteLine("File Type is " + fileList[i].GetType());
Console.WriteLine("File Url is " + fileList[i].GetUrl());
Console.WriteLine("File Description is " + fileList[i].GetDescription());
} 
String jsonResponse = fileList.ToString(); /* 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/c4dq3w7",
                        "description": "TextFile_123"
                    }
                }
            }
        }
    }
}
public void GetAllFiles(App42Callback requestCallback)

Gets all the files for the App.

Parameters:

requestCallback - Callback instance that will have the implementation of OnSuccess & OnException of App42Callback.

Returns:

Upload object

Response: Upload Object

Exception:

This method throws following exception.
/*
2101 - NOT FOUND - Files do not exist. 
*/ 		        
For more details click Exception
uploadService.GetAllFiles(requestCallback); /* returns the Upload object. */  
OnSuccess(Object obj){
Upload upload = (Upload) obj;  
IList<Upload.File> fileList =  upload.GetFileList(); /* returns the upload file list. */
for (int i = 0; i < fileList.Count; i++)
{
Console.WriteLine("File Name is " + fileList[i].GetName());
Console.WriteLine("File Type is " + fileList[i].GetType());
Console.WriteLine("File Url is " + fileList[i].GetUrl());
Console.WriteLine("File Description is " + fileList[i].GetDescription());
} 
String jsonResponse = fileList.ToString(); /* 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/c2yx846",
                            "description": "TextFile_123"
                        },
                        {
                            "name": "TextFile007",
                            "type": "TXT",
                            "url": "http://XXXX.txt",
							"tinyUrl": "http://tinyurl.com/d2jxah4",
                            "description": "TextFile_123"
                        }
                    ]
                }
            }
        }
    }
}
public void GetAllFilesCount(App42Callback requestCallback)

Gets count of all the files for the App

Parameters:

requestCallback - Callback instance that will have the implementation of OnSuccess & OnException of App42Callback.

Returns:

App42Response object

Response: App42Response Object

For more details click Exception
uploadService.GetAllFilesCount(requestCallback); /* returns the App42Response  object. */ 
OnSuccess(Objcet obj)
{
Upload upload = (Upload) obj;
App42Response response = (App42Response) upload;
Boolean success = response.IsResponseSuccess();
int totalRecords = response.GetTotalRecords();
String jsonResponse = response.ToString(); /* returns the response in JSON format. (as shown below)*/
}
{
    "app42": {
        "response": {
            "success": true,
            "totalRecords": 3
        }
    }
}
public void GetAllFiles(int max, int offset, App42Callback requestCallback)

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
requestCallback - Callback instance that will have the implementation of OnSuccess & OnException of App42Callback.

Returns:

Upload object

Response: Upload Object

Exception:

This method throws following exception.
/*
2106 - NOT FOUND - The number of files are less than the specified offset : <offset>.
*/	    
For more details click Exception
int max = 1;
int offset = 0; 

uploadService.GetAllFiles(max,offset,requestCallback); /* returns the Upload object. */  
OnSuccess(Object obj){
Upload upload = (Upload) obj;  
IList<Upload.File> fileList =  upload.GetFileList(); /* returns the upload file list. */
for (int i = 0; i < fileList.Count; i++)
{
Console.WriteLine("File Name is " + fileList[i].GetName());
Console.WriteLine("File Type is " + fileList[i].GetType());
Console.WriteLine("File Url is " + fileList[i].GetUrl());
Console.WriteLine("File Description is " + fileList[i].GetDescription());
} 
String jsonResponse = fileList.ToString(); /* 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/c2yx846",
                        "description": "desc"
                    }
                }
            }
        }
    }
}
public void GetFileByName(String name, App42Callback requestCallback)

Gets the file based on file name.

Parameters:

name - The name of the file which has to be retrieved
requestCallback - Callback instance that will have the implementation of OnSuccess & OnException of App42Callback.

Returns:

Upload object

Response: Upload Object

Exception:

This method throws following exception.
/*
2103 - NOT FOUND - The file with the name '<name>' does not exist. 
*/ 		    
For more details click Exception
String name = "TextFile01";
uploadService.GetFileByName(name,requestCallback); /* returns the Upload object. */  
OnSuccess(Object obj){
Upload upload = (Upload) obj;  
IList<Upload.File> fileList =  upload.GetFileList(); /* returns the upload file list. */
for (int i = 0; i < fileList.Count; i++)
{
Console.WriteLine("File Name is " + fileList[i].GetName());
Console.WriteLine("File Type is " + fileList[i].GetType());
Console.WriteLine("File Url is " + fileList[i].GetUrl());
Console.WriteLine("File Description is " + fileList[i].GetDescription());
} 
String jsonResponse = fileList.ToString(); /* 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/ccny2tz",
                        "description": "TextFile_123"
                    }
                }
            }
        }
    }
}
public void GetFilesByType(String uploadFileType, App42Callback requestCallback)

Get the files based on file type.

Parameters:

uploadFileType - Type of the file e.g. Upload.AUDIO, Upload.XML etc.
requestCallback - Callback instance that will have the implementation of OnSuccess & OnException of App42Callback.

Returns:

Upload object

Response: Upload Object

Exception:

This method throws following exception.
/*
2105 - NOT FOUND - The file with type '<type>' does not exist.
*/ 		 
For more details click Exception
String uploadFileType = UploadFileType.IMAGE;

uploadService.GetFilesByType(uploadFileType,requestCallback); /* returns the Upload object. */  
OnSuccess(Object obj){
Upload upload = (Upload) obj;  
IList<Upload.File> fileList =  upload.GetFileList(); /* returns the upload file list. */
for (int i = 0; i < fileList.Count; i++)
{
Console.WriteLine("File Name is " + fileList[i].GetName());
Console.WriteLine("File Type is " + fileList[i].GetType());
Console.WriteLine("File Url is " + fileList[i].GetUrl());
Console.WriteLine("File Description is " + fileList[i].GetDescription());
} 
String jsonResponse = fileList.ToString(); /* 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/d2jxah4",
                            "description": "TextFile_123"
                        },
                        {
                            "name": "TextFile007",
                            "type": "TXT",
                            "url": "http://XXXX.txt",
                            "tinyUrl": "http://tinyurl.com/c2yx846",
                            "description": "TextFile_123"
                        }
                    ]
                }
            }
        }
    }
}
public void GetFilesCountByType(String uploadFileType, App42Callback requestCallback)

Get the count of files based on file type.

Parameters:

uploadFileType - Type of the file e.g. Upload.AUDIO, Upload.XML etc.
requestCallback - Callback instance that will have the implementation of OnSuccess & OnException of App42Callback.

Returns:

App42Response object

Response: App42Response Object

For more details click Exception
String uploadFileType = UploadFileType.IMAGE;

uploadService.GetFilesCountByType(uploadFileType ,requestCallback); /* returns the App42Response  object. */ 
OnSuccess(Objcet obj){
Upload upload = (Upload) obj;
App42Response response = (App42Response) upload;
Boolean success = response.IsResponseSuccess();
int totalRecords = response.GetTotalRecords();
String jsonResponse = response.ToString(); /* returns the response in JSON format. (as shown below)*/
}
{
    "app42": {
        "response": {
            "success": true,
            "totalRecords": 3
        }
    }
}
public void GetFilesByType(String uploadFileType, int max, int offset, App42Callback requestCallback)

Get the files based on file type by paging.

Parameters:

fileType - 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
requestCallback - Callback instance that will have the implementation of OnSuccess & OnException of App42Callback.

Returns:

Upload object

Response: Upload Object

Exception:

This method throws following exception.
/*
2108 - NOT FOUND - The number of files with type '<type>' are less than the specified offset : <offset>. 
*/ 		       
For more details click Exception
String uploadFileType = UploadFileType.AUDIO;
int max = 1;
int offset = 0;	

uploadService.GetFilesByType(uploadFileType,max,offset,requestCallback); /* returns the Upload object. */  
OnSuccess(Object obj){
Upload upload = (Upload) obj;  
IList<Upload.File> fileList =  upload.GetFileList(); /* returns the upload file list. */
for (int i = 0; i < fileList.Count; i++)
{
Console.WriteLine("File Name is " + fileList[i].GetName());
Console.WriteLine("File Type is " + fileList[i].GetType());
Console.WriteLine("File Url is " + fileList[i].GetUrl());
Console.WriteLine("File Description is " + fileList[i].GetDescription());
} 
String jsonResponse = fileList.ToString(); /* 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/d2jxah4",
                        "description": "desc"
                    }
                }
            }
        }
    }
}
public void RemoveFileByName(String name, App42Callback requestCallback)

Removes the file based on file name.

Parameters:

name - The name of the file which has to be removed
requestCallback - Callback instance that will have the implementation of OnSuccess & OnException of App42Callback.

Returns:

App42Response if deleted successfully

Response: App42Response Object

Exception:

This method throws following exception.
/*
2103 - NOT FOUND - The file with the name '<name>' does not exist. 
*/  		       
For more details click Exception
String name = "TextFile007";

uploadService.RemoveFileByName(name,requestCallback); /* returns the App42Response object. */
OnSuccess(Objcet obj){
Upload upload = (Upload) obj;
App42Response response = (App42Response) upload;
Boolean success = response.IsResponseSuccess();
String jsonResponse = response.ToString(); /* 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/cchwmfj",
                        "description": "TextFile_098"
                    }
                }
            }
        }
    }
}
public void RemoveAllFiles(App42Callback requestCallback)

Removes all the files for the App

Parameters:

requestCallback - Callback instance that will have the implementation of OnSuccess & OnException of App42Callback.

Returns:

App42Response if deleted successfully

Response: App42Response Object

Exception:

This method throws following exception.
/*
2104 - NOT FOUND - There are no files to remove.
*/ 		     
For more details click Exception
uploadService.RemoveAllFiles(requestCallback); /* returns the App42Response object. */
OnSuccess(Objcet obj){
Upload upload = (Upload) obj;
App42Response response = (App42Response) upload;
Boolean success = response.IsResponseSuccess();
String jsonResponse = response.ToString(); /* 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/d2jxah4",
                            "description": "Audio123"
                        },
                        {
                            "name": "FILEName01755",
                            "userName": "Nick",
                            "type": "AUDIO",
                            "url": "http://YYYY.mp3",
                            "tinyUrl": "http://tinyurl.com/c2yx846",
                            "description": "Audio123"
                        }
                    ]
                }
            }
        }
    }
}
public void UploadFileForUser(String name, String userName, Stream stream, String fileType, String description, App42Callback requestCallback)

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.
stream - The sequence of bytes for the fileList[i].
fileType - The type of the fileList[i]. 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.
requestCallback - Callback instance that will have the implementation of OnSuccess & OnException of App42Callback.

Returns:

Upload object

Response: Upload Object

Exception:

This method throws following exception.
/*
2100 - BAD REQUEST - The request parameters are invalid. File by the name '<name>' already exists.
*/ 		      
For more details click Exception
String name = "File03";
String userName = "Nick";
Stream stream = "local file stream";
String uploadFileType = UploadFileType.TXT;
String description = "TextFile_098";
	
uploadService.UploadFileForUser(name,userName,stream,fileType,description); /* returns the Upload object. */  
OnSuccess(Object obj){
Upload upload = (Upload) obj;  
IList<Upload.File> fileList =  upload.GetFileList(requestCallback); /* returns the upload file list. */
for (int i = 0; i < fileList.Count; i++)
{
Console.WriteLine("File Name is " + fileList[i].GetName());
Console.WriteLine("File Type is " + fileList[i].GetType());
Console.WriteLine("File Url is " + fileList[i].GetUrl());
Console.WriteLine("File Description is " + fileList[i].GetDescription());
} 
String jsonResponse = fileList.ToString(); /* 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/blah4mc",
                        "description": "TextFile_098"
                    }
                }
            }
        }
    }
}
public void GetFileByUser(String name, String userName, App42Callback requestCallback)

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
requestCallback - Callback instance that will have the implementation of OnSuccess & OnException of App42Callback.

Returns:

Upload object

Response: Upload Object

Exception:

This method throws following exception.
/*
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
String name = "File03";
String userName = "Nick";

uploadService.GetFileByUser(name,userName,requestCallback); /* returns the Upload object. */  
OnSuccess(Object obj)
{
Upload upload = (Upload) obj;  
IList<Upload.File> fileList =  upload.GetFileList(); /* returns the upload file list. */
for (int i = 0; i < fileList.Count; i++)
{
Console.WriteLine("File Name is " + fileList[i].GetName());
Console.WriteLine("File Type is " + fileList[i].GetType());
Console.WriteLine("File Url is " + fileList[i].GetUrl());
Console.WriteLine("File Description is " + fileList[i].GetDescription());
} 
String jsonResponse = fileList.ToString(); /* 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/c4zzdgg",
                        "description": "TextFile_098"
                    }
                }
            }
        }
    }
}
public void GetAllFilesByUser(String userName, App42Callback requestCallback)

Get all the files based on user name.

Parameters:

userName - The name of the user for which file has to be retrieved
requestCallback - Callback instance that will have the implementation of OnSuccess & OnException of App42Callback.

Returns:

Upload object

Response: Upload Object

Exception:

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

uploadService.GetAllFilesByUser(userName,requestCallback); /* returns the Upload object. */  
OnSuccess(Object obj){
Upload upload = (Upload) obj;  
IList<Upload.File> fileList =  upload.GetFileList(); /* returns the upload file list. */
for (int i = 0; i < fileList.Count; i++)
{
Console.WriteLine("File Name is " + fileList[i].GetName());
Console.WriteLine("File Type is " + fileList[i].GetType());
Console.WriteLine("File Url is " + fileList[i].GetUrl());
Console.WriteLine("File Description is " + fileList[i].GetDescription());
} 
String jsonResponse = fileList.ToString(); /* 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/crn84ov",
                            "description": "Image_012"
                        },
                        {
                            "name": "File03",
                            "userName": "Nick",
                            "type": "TXT",
                            "url": "http://XXXX.txt",
                            "tinyUrl": "http://tinyurl.com/czndfwg",
                            "description": "TextFile_098"
                        }
                    ]
                }
            }
        }
    }
}
public void GetAllFilesCountByUser(String userName, App42Callback requestCallback)

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
requestCallback - Callback instance that will have the implementation of OnSuccess & OnException of App42Callback.

Returns:

App42Response object

Response: App42Response Object

For more details click Exception
String userName = "Nick";

uploadService.GetAllFilesCountByUser(userName,requestCallback); /* returns the App42Response  object. */ 
OnSuccess(Objcet obj)
{
Upload upload = (Upload) obj;
App42Response response = (App42Response) upload;
Boolean success = response.IsResponseSuccess();
int totalRecords = response.GetTotalRecords();
String jsonResponse = response.ToString(); /* returns the response in JSON format. (as shown below)*/
}
{
    "app42": {
        "response": {
            "success": true,
            "totalRecords": 3
        }
    }
}
public void GetAllFilesByUser(String userName, int max, int offset, App42Callback requestCallback)

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
requestCallback - Callback instance that will have the implementation of OnSuccess & OnException of App42Callback.

Returns:

Upload object

Response: Upload Object

Exception:

This method throws following exception.
/*
2107 - NOT FOUND - The number of files for the user '<userName>' are less than the specified offset : <offset>. 
*/ 		        
For more details click Exception
String userName = "Nick";
int max = 1;
int offset = 0;

uploadService.GetAllFilesByUser(userName,max,offset,requestCallback); /* returns the Upload object. */  
OnSuccess(Object obj){
Upload upload = (Upload) obj;  
IList<Upload.File> fileList =  upload.GetFileList(); /* returns the upload file list. */
for (int i = 0; i < fileList.Count; i++)
{
Console.WriteLine("File Name is " + fileList[i].GetName());
Console.WriteLine("File Type is " + fileList[i].GetType());
Console.WriteLine("File Url is " + fileList[i].GetUrl());
Console.WriteLine("File Description is " + fileList[i].GetDescription());
} 
String jsonResponse = fileList.ToString(); /* 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/cpzgtch",
                        "description": "Image123"
                    }
                }
            }
        }
    }
}
public void RemoveFileByUser(String name, String userName, App42Callback requestCallback)

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
requestCallback - Callback instance that will have the implementation of OnSuccess & OnException of App42Callback.

Returns:

App42Response if deleted successfully

Response: App42Response Object

Exception:

This method throws following exception.
/*
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
String name = "File03";
String userName = "Nick";

uploadService.RemoveFileByUser(name, userName,requestCallback); /* returns the App42Response object. */
OnSuccess(Objcet obj){
Upload upload = (Upload) obj;
App42Response response = (App42Response) upload;
Boolean success = response.IsResponseSuccess();
String jsonResponse = response.ToString(); /* 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/d37fkmh",
                        "description": "TextFile_098"
                    }
                }
            }
        }
    }
}
public void RemoveAllFilesByUser(String userName, App42Callback requestCallback)

Removes the file based on user name.

Parameters:

userName - The name of the user for which file has to be removed
requestCallback - Callback instance that will have the implementation of OnSuccess & OnException of App42Callback.

Returns:

App42Response if deleted successfully

Response: App42Response Object

Exception:

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

uploadService.RemoveAllFilesByUser(userName,requestCallback); /* returns the App42Response object. */
OnSuccess(Objcet obj){
Upload upload = (Upload) obj;
App42Response response = (App42Response) upload;
Boolean success = response.IsResponseSuccess();
String jsonResponse = response.ToString(); /* 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/crn84ov",
                            "description": "Image_012"
                        },
                        {
                            "name": "File03",
                            "userName": "Billy",
                            "type": "TXT",
                            "url": "http://XXXX.txt",
							"tinyUrl": "http://tinyurl.com/czndfwg",
                            "description": "Image_013"
                        }
                    ]
                }
            }
        }
    }
}