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
But, When I called UploadFile function I am getting error...

"Message is 1401   
Message is 401   
Message is UnAuthorized Access   
Message is Client is not authorized for this operation"   

Even User logged in successfully...

Can you please tell me how to use Upload File Service in corona sdk?
I was gone through your Doc for use of this API, but it throwing above exceptions
Are you working with ACL app for uploading file on App42 Server?
For Audio upload:
What I am doing is, first recording voice in app and upload that Audio file on cloud and Broadcast Audio URL to other players, this process for App to Cloud operation and Cloud to App.

And For Images Upload:
For Images we will upload images from Web to Cloud. Then fetch from Cloud to App.
Right now I am focusing on "Upload Audio" on cloud using upload file Service, so please tell me about Audio uploading in corona sdk, Why it throwing Error  "Client is not authorized for this operation" when I was uploading audio....
Are you working with acl enable app to upload file on App42 server?
Because the above exception occur only when you are uploading a file on App42 server without specifying the sessionid or adminKey.
Kindly check and let me know if it helps.
I have specifying sessionId and also appkey.

What is AdminKey?
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
...