You can also save binary data (Files) like audio/video/images/txt etc. on the App42 cloud using the File Upload Service. Whenever your app file is uploaded it is stored on our CDN network and can be accessed by its unique http end point URL.
You can save any binary file to App42 Cloud with a few lines of code as shown below. File name will be used to uniquely refer to the uploaded file. Once your file is uploaded, you will get an http end point for this file that you can use in your app for fetching it from the App42 CDN network.
String name = "MyPic"; String userName = "Nick"; String filePath = " file path from gallery /sd card"; String description = "This is my holiday pic"; // File will get uploaded on the App42 cloud using the below snippet uploadService.uploadFileForUser(name,userName,filePath,UploadFileType.IMAGE,description new App42CallBack() { public void onSuccess(Object response) { Upload upload = (Upload)response; // This will have only a single file uploaded above ArrayList<Upload.File> fileList = upload.getFileList(); for(int i = 0; i < fileList.size();i++ ) { System.out.println("fileName is :" + fileList.get(i).getName()); System.out.println("fileType is :" + fileList.get(i).getType()); System.out.println("fileUrl is :" + fileList.get(i).getUrl()); System.out.println("Tiny Url is :"+fileList.get(i).getTinyUrl()); System.out.println("fileDescription is: " + fileList.get(i).getDescription()); } } public void onException(Exception ex) { System.out.println("Exception Message"+ex.getMessage()); } });NSString *name = @"MyPic"; NSString *name = @"Nick"; NSString *filePath = @"file path from gallery /sd card"; NSString *fileType = IMAGE; NSString *description = @"This is my holiday pic"; Upload *upload = [uploadServiceObject uploadFileForUser:name userName:userName filePath:filePath uploadFileType:fileType description:description]; // File will get uploaded on the App42 cloud with above snippet. returns the Upload object. */ NSMutableArray *fileList = upload.fileListArray; // This will have only single file uploaded above for(File *file in fileList) { NSLog(@"File Url is %@" , file.url); //This will return uploaded file URL }String fileName = "MyPic"; String userName = "Nick"; String description = "This is my holiday pic"; Stream inputStream = "Stream of file "; /* Get result of photo chooser task */ uploadService.UploadFileForUser(fileName,userName,inputStream,"Your File Type",description,requestCallback); /* requestCallback points instance of App42Callback which overrides OnSuccess and OnException method */ //Implemented request Callback method void OnSuccess(Object response) { Upload upload = (Upload) response; IList<Upload.File> fileList = upload.GetFileList(); // This will have only single file uploaded above for (int i = 0; i < fileList.Count; i++) { Console.WriteLine("fileUrl is " + fileList[i].GetUrl()); //This will return uploaded file url } }String name = "MyPic"; String userName = "Nick"; String filePath = " file path from gallery /sd card"; String description = "This is my holiday pic"; Upload upload = uploadService.uploadFileForUser(name,userName,filePath,UploadFileType.IMAGE,description); // File will get uploaded in App42 cloud with above snippet. Vector fileList = upload.getFileList(); for(int i=0;i < fileList.size();i++) { Upload.File file = (Upload.File) fileList.elementAt(i); System.out.println("File Url is " + file.getUrl()); //This will return uploaded file URL }var fileName = "MyPic", userName = "Nick", description = "File Description", filePath = " file path from gallery /sd card", result ; uploadService.uploadFileForUser(fileName,userName,filePath,"Your File Type",description,{ success: function(object) { // File will get uploaded in App42 cloud with above snippet. var uploadObj = JSON.parse(object); result = uploadObj.app42.response.upload; console.log("result is " + result) }, error: function(error) { } });String name = "MyPic"; String userName = "Nick"; String filePath = " file path from gallery /sd card"; String description = "This is my holiday pic"; Upload upload = uploadService.uploadFileForUser(name,userName,filePath,UploadFileType.IMAGE,description); // File will get uploaded on the App42 cloud using the above snippet ArrayList<Upload.File> fileList = upload.getFileList(); // This will have only a single file uploaded above for(Upload.File file : fileList) { System.out.println("File Url is " + file.getUrl()); //This will return uploaded file URL }String fileName = "MyPic"; String userName = "Nick"; String description = "File Description"; String filePath = "Your Local File Path"; String fileType = "<Your_file_type>"; App42Log.SetDebug(true); //Prints output in your editor console uploadService.UploadFileForUser(fileName, userName, filePath, fileType, description, new UnityCallBack()); public class UnityCallBack : App42CallBack { public void OnSuccess(object response) { Upload upload = (Upload) response; IList<Upload.File> fileList = upload.GetFileList(); for(int i=0; i < fileList.Count; i++) { App42Log.Console("fileName is " + fileList[i].GetName()); App42Log.Console("fileType is " + fileList[i].GetType()); App42Log.Console("fileUrl is " + fileList[i].GetUrl()); App42Log.Console("TinyUrl Is : " + fileList[i].GetTinyUrl()); App42Log.Console("fileDescription is " + fileList[i].GetDescription()); } } public void OnException(Exception e) { App42Log.Console("Exception : " + e); } }String name = "MyPic"; String userName = "Nick"; String filePath = " file path from gallery /sd card"; String fileType = "IMAGE"; String description = "This is my holiday pic"; Upload upload = uploadService.UploadFileForUser(name,userName,filePath,fileType,description); // File will get uploaded in App42 cloud with above snippet. IList<Upload.File> fileList = upload.GetFileList(); // This will have only single file uploaded above for (int i = 0; i < fileList.Count; i++) { Console.WriteLine("fileUrl is " + fileList[i].GetUrl()); //This will return uploaded file URL }$name = "MyPic"; $userName = "Nick"; $filePath = "Local file path"; fileType = UploadFileType::IMAGE; $description = "This is my holiday pic"; $uploadService = $upload->uploadFileForUser($fileName,$userName, $filePath, $fileType, $description); // File will get uploaded on the App42 cloud using the above snippet $fileList = $upload->getFileList(); // This will have only a single file uploaded above foreach( $fileList as $file ) { Print_r("File Url is " . $file->getUrl()); //This will return uploaded file URL }name = "MyPic"; userName = "Nick"; filePath = " file path from gallery /sd card"; fType = App42::Upload::UploadFileType.new(); uploadFileType = fType.enum("IMAGE"); description = "This is my holiday pic"; upload = uploadService.upload_file_for_user(name,userName,filePath,uploadFileType,description); // File will get uploaded on the App42 cloud using the above snippet fileList = Array.new(); for file in fileList do // This will have only a single file uploaded above puts "url is #{file.url}"; //This will return the uploaded file URL endN/AN/A
An Uploaded file can be fetched using its file name and username. This will return the http end point of the file name passed.
String name = "MyPic"; String userName = "Nick"; // Following statement will fetch file info from the App42 Cloud uploadService.getFileByUser(name,userName, new App42CallBack() { public void onSuccess(Object response) { Upload upload = (Upload)response; // This will have only a single file fetched as a user can have only one file with the given name ArrayList<Upload.File> fileList = upload.getFileList(); for(int i = 0; i < fileList.size();i++ ) { System.out.println("fileName is :" + fileList.get(i).getName()); System.out.println("fileType is :" + fileList.get(i).getType()); System.out.println("fileUrl is :" + fileList.get(i).getUrl()); System.out.println("Tiny Url is :"+fileList.get(i).getTinyUrl()); System.out.println("fileDescription is: " + fileList.get(i).getDescription()); } } public void onException(Exception ex) { System.out.println("Exception Message"+ex.getMessage()); } });NSString *name = @"MyPic"; NSString *name = @"Nick"; Upload *upload = [uploadServiceObject getFileByUser:name userName:userName]; // Above statement will fetch file info from the App42 Cloud NSMutableArray *fileList = upload.fileListArray; // This will have only a single file uploaded above for(File *file in fileList) { NSLog(@"File Url is %@" , file.url); //This will return uploaded file URL }String name = "MyPic"; String userName = "Nick"; uploadService.GetFileByUser(name,userName,requestCallback); /* requestCallback points instance of App42Callback which overrides OnSuccess and OnException method */ // Above statement will fetch file info from the App42 Cloud //Implemented request Callback method void OnSuccess(Object response) { Upload upload = (Upload) response; IList<Upload.File> fileList = upload.GetFileList(); // This will have only a single file fetched as a user can have only one file with a given name for (int i = 0; i < fileList.Count; i++) { Console.WriteLine("fileUrl is " + upload.GetFileList()[i].GetUrl()); //This will return file url info } }String name = "MyPic"; String userName = "Nick"; Upload upload = uploadService.getFileByUser(name,userName); // Above statement will fetch file info from the App42 Cloud Vector fileList = upload.getFileList(); // This will have only a single file fetched as a user can have only one file with a given name for(int i=0;i < fileList.size();i++) { Upload.File file = (Upload.File) fileList.elementAt(i); System.out.println("File Url is " + file.getUrl()); //This will return file URL info }var name = "MyPic", userName = "Nick", result ; uploadService.getFileByUser(name,userName,{ success: function(object) { // Above statement will fetch file info from the App42 Cloud var uploadObj = JSON.parse(object); result = uploadObj.app42.response.upload; console.log("File Url is " + result.files.file.url) }, error: function(error) { } });String name = "MyPic"; String userName = "Nick"; Upload upload = uploadService.getFileByUser(name,userName); // Above statement will fetch file info from the App42 Cloud ArrayList<Upload.File> fileList = upload.getFileList(); // This will have only a single file fetched as a user can have only one file with a given name for(Upload.File file : fileList) { System.out.println("File Url is " + file.getUrl()); //This will return file URL info }String fileName = "MyPic"; String userName = "Nick"; App42Log.SetDebug(true); //Prints output in your editor console uploadService.GetFileByUser(fileName, userName, new UnityCallBack()); public class UnityCallBack : App42CallBack { public void OnSuccess(object response) { Upload upload = (Upload) response; IList<Upload.File> fileList = upload.GetFileList(); for(int i=0; i < fileList.Count; i++) { App42Log.Console("fileName is " + fileList[i].GetName()); App42Log.Console("fileType is " + fileList[i].GetType()); App42Log.Console("fileUrl is " + fileList[i].GetUrl()); App42Log.Console("TinyUrl Is : " + fileList[i].GetTinyUrl()); App42Log.Console("fileDescription is " + fileList[i].GetDescription()); } } public void OnException(Exception e) { App42Log.Console("Exception : " + e); } }String name = "MyPic"; String userName = "Nick"; Upload upload = uploadService.GetFileByUser(name,userName); // Above statement will fetch file info from the App42 Cloud IList<Upload.File> fileList = upload.GetFileList(); // This will have only a single file fetched as a user can have only one file with the given name for (int i = 0; i < fileList.Count; i++) { Console.WriteLine("fileUrl is " + fileList[i].GetUrl()); //This will return file URL info }$fileName = "MyPic"; $userName = "Nick"; uploadService = $upload->getFileByUser($fileName, $userName); // Above statement will fetch file info from App42 Cloud $fileList = $upload->getFileList(); // This will have only a single file fetched as a user can have only one file with a given name foreach( $fileList as $file ) { Print_r("File Url is " . $file->getUrl()); //This will return file URL info }name = "MyPic"; userName = "Nick"; upload = uploadService.get_file_by_user(name,userName); // Above statement will fetch file info from the App42 Cloud fileList = Array.new(); for file in fileList do // This will have only a single file fetched as a user can have only one file with a given name puts "url is #{file.url}"; //This will return file URL info endN/AN/A