could not get id of file after upload

4 posts, 0 answers
  1. jon
    jon avatar
    20 posts
    Member since:
    Jul 2014

    Posted 01 Sep 2014 Link to this post

    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.
  2. jon
    jon avatar
    20 posts
    Member since:
    Jul 2014

    Posted 01 Sep 2014 in reply to jon Link to this post

    sorry I meant

    alert(r.response.Result[0].Id);
  3. jon
    jon avatar
    20 posts
    Member since:
    Jul 2014

    Posted 01 Sep 2014 Link to this post

    hi, i managed to get the id by using a JSON.parse
  4. Anton Dobrev
    Admin
    Anton Dobrev avatar
    539 posts

    Posted 03 Sep 2014 Link to this post

    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.
     
Back to Top