Add File Storage Backend to Mobile App using Corona API

App42 has recently added a simple but a very useful feature i.e, File upload using Corona SDK. Now you can easily upload your file on the cloud using this feature. File type supported are AUDIO, VIDEO , IMAGE , BINARY , TXT ,XML , CSV , JSON , OTHER. Rather than storing file on your local storage, you can upload your file directly on the cloud. Now a days file storage feature is mostly used in chat applications, which helps in sharing media file between buddies e.g images,video ,audio etc .

Steps to use this feature in your corona app : 

  • Register with App42 platform
  • Create your App, once you are on quick start page .
  • Download App42 Corona SDK from here and unzip it on your machine.
  • Copy the App42 Lua API folder in your sample project
  • Use the below code snippet which helps in saving your file on App42 Cloud

Design Details :

Initialize App42 API instance and upload service using the below code snippet:

1
2
App42API:initialize("API_KEY""SECRET_KEY")
local uploadService = App42API:buildUploadService()

After initializing the App42 service instance use the below code snippet which is used to upload your media file to our cdn network. Choose the file from your local system/mobile and upload to our cdn network .

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
local fileName = "<Your_file_name>";
local description = "File Description";
local filePath = "Your Local File Path";
local fileType = "<Your_file_type>";
local App42CallBack = {}
 
uploadService:uploadFile(fileName,filePath ,fileType,description,App42CallBack)
 
function App42CallBack:onSuccess(object)
   print("fileName is :".. object:getFileList():getName());
   print("Type is :".. object:getFileList():getType());
   print("Url is :".. object:getFileList():getUrl());
   print("fileDescription is: ".. object:getFileList():getDescription());
end
 
function App42CallBack:onException(exception)
print("Message is : "..exception:getMessage())
print("App Error code is : "..exception:getAppErrorCode())
print("Http Error code is "..exception:getHttpErrorCode())
print("Detail is : "..exception:getDetails())
end

There are many more methods through which you can upload file for your app user and also retrieve the same file from cdn using various method of corona sdk . For further information on our Corona SDK, you can visit our docs.

You can also visit our AppHQ Management Console to manage your data. You can find your uploaded file under Technical Service Manager -> Upload Service.

BlogImage8 Add File Storage Backend to Mobile App using Corona API

In this blog, I have explained about the process of uploading files on cloud using App42 Corona SDK.

If you have any question or need further assistance, please feel free to write to us at support@shephertz.com

twitter Add File Storage Backend to Mobile App using Corona APIfacebook Add File Storage Backend to Mobile App using Corona APIgoogle Add File Storage Backend to Mobile App using Corona APIlinkedin Add File Storage Backend to Mobile App using Corona APIpinterest Add File Storage Backend to Mobile App using Corona APIreddit Add File Storage Backend to Mobile App using Corona APIstumbleupon Add File Storage Backend to Mobile App using Corona APItumblr Add File Storage Backend to Mobile App using Corona API

Leave a Reply

Your email address will not be published. Required fields are marked *


− five = 3

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>