Upload file on cloud API for Corona SDK?

0 votes
Hi,

Still we are wating for Upload Service API for Corona SDk, you guys told it will be launch on 5th August 2014.

Please tell when it will be launch, because we are stuck without it.
asked Aug 5, 2014 in App42 Cloud API-BaaS by imtiyaz (45 points)

1 Answer

+2 votes
 
Best answer

Hi Imtiyaz,

Thanks for having patience.

Kindly download latest version of Corona sdk from here which contain the file storage service feature. For detail documentation of api, you can check our docs from here for the file storage service.

Let me know if it helps.

Thanks.

answered Aug 5, 2014 by hs00105 (517 points)
selected Aug 6, 2014 by imtiyaz
For security purposes, session Id is required when there is user specific interaction. For example when you are uploading a file of a user then you need to pass session id of that user. Below is the code snippet which explains better:

uploadService:setSessionId("SessionId of Nick");
uploadService:uploadFileForUser("Name of File","Nick","File Path",UploadFileType.IMAGE,"Description",callBack)
function callBack:onSuccess(object)
   print("fileName is :".. object:getFileList():getName());
   print("UserName is :".. object:getFileList():getUserName());
   print("Type is :".. object:getFileList():getType());     
   print("Url is :".. object:getFileList():getUrl());  
   print("Description is: ".. object:getFileList():getDescription());  
end  
function callBack:onException(object)
    print("Message is "..object:getMessage());
    print("Message details is "..object:getDetails());
end
 
In case Admin is uploading a file, you need to setAdminKey in upload service instance. Below is the code snippet:
 
local fileName = "<Your_file_name>";
local description = "File Description";    
local filePath = "Your Local File Path";
local fileType = "<Your_file_type>";
local App42CallBack = {}
uploadService:setAdminKey("Admin Key of App")
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(object)
            print("Message is "..object:getAppErrorCode());
            print("Message is "..object:getHttpErrorCode());
            print("Message is "..object:getMessage());
            print("Message is "..object:getDetails());
end
 
Let me know if it helps.
Thanks
Will check and Let you know tomorrow.

Thanks for prompt reply.
Its working fine

Thank you very much
can u explain what is the difference between admin uploading file and user uploading file?

Thank you
If file is owned by a user, it is user file. For example profile photo of user. If file is app file, it is admin file. For example assets file for app or header image of app.
Download Widgets
Welcome to ShepHertz Product line forum, where you can ask questions and receive answers from the community. You can also reach out to us on support@shephertz.com
...