Upload handler. Cannot return id of created items to client.

2 posts, 1 answers
  1. Evgeny
    Evgeny avatar
    1 posts
    Member since:
    Aug 2012

    Posted 10 Aug 2012 Link to this post

    I am uploading few files and i want to return their ids to client. 

    What i am do for that:

    List<int> _listOfIds
    public override Dictionary<string, object> GetAssociatedData()
    {
     if (IsFinalUploadRequest())
                {
                    dict.Add("MyIds", _listOfIds);
                }
    }

      public override void ProcessStream()
      {
    base.ProcessStream();

     if (IsFinalUploadRequest())
      { 

    //CODE to save item to database.
    int savedId=SomeId();
    _listOfIds.Add(savedId );
    }
    }


    Problem here that GetAssociatedData is called earlier than i will recieve item ID!! What i suppose to do?
    Can i send GetAssociatedData() after my manipulations to store data in DB?
  2. Answer
    Tina Stancheva
    Admin
    Tina Stancheva avatar
    3298 posts

    Posted 15 Aug 2012 Link to this post

    Hi Evgeny,

    In order to implement your solution, you need to override the SaveChunkData() method instead of the ProssessStream() method. I prepared a sample solution demonstrating a possible approach for your scenario - please note that I send over to the client side the id-s one by one thus populating the collection of ids on the client. Let me know if that helps.

    Regards,
    Tina Stancheva
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  3. DevCraft banner
Back to Top