This is a migrated thread and some comments may be shown as answers.

could not get id of file after upload

3 Answers 41 Views
Bugs & Issues
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
jon
Top achievements
Rank 1
jon asked on 01 Sep 2014, 03:51 PM
I am using the Friends app and code from http://docs.telerik.com/platform/backend-services/development/javascript-sdk/files/upload-files

I could upload a file but I could not get its Id

ft.upload(imageURI, uploadUrl, function (r) {
alert('success');
alert(r.resource.Result[0).Id);
 }, function(error){
alert("An error has occurred: Code = " + error.code);
}, options)

please advise, thanks in advance.

3 Answers, 1 is accepted

Sort by
0
jon
Top achievements
Rank 1
answered on 01 Sep 2014, 03:52 PM
sorry I meant

alert(r.response.Result[0].Id);
0
jon
Top achievements
Rank 1
answered on 02 Sep 2014, 02:14 AM
hi, i managed to get the id by using a JSON.parse
0
Anton Dobrev
Telerik team
answered on 03 Sep 2014, 10:16 AM
Hello Jon,

We are glad to hear that everything is working on your side.

Here is the actual code so that it is available in this forum thread:
ft.upload(imageURI, uploadUrl, function(r) {
    var responseCode = r.responseCode;
 
    var res = JSON.parse(r.response);
    var uploadedFileId = res.Result[0].Id;
    var uploadedFileUri = res.Result[0].Uri;

}, function(error) {
    alert("An error has occurred:" + JSON.stringify(error));
}, options)

Regards,
Anton Dobrev
Telerik
 
Everlive is now Telerik Backend Services, and is part of the Telerik Platform.
 
Tags
Bugs & Issues
Asked by
jon
Top achievements
Rank 1
Answers by
jon
Top achievements
Rank 1
Anton Dobrev
Telerik team
Share this question
or