Chunk upload. Files property.

2 posts, 1 answers
  1. Mike
    Mike avatar
    1 posts
    Member since:
    Oct 2019

    Posted 31 Oct 2019 Link to this post

    We use chunk upload of files to send large files asynchronously with multiple requests.

    I want to add custom field to each request (for example File ID) using e.data property.

    This custom field has one-to-one relation (file ID <-> file).

     

    I found out property -> e.files is Array (A list of the files that will be uploaded).

    It means that upload event be triggered for multiple files.

     

    I can`t understand cases when this field may contain more than one record (for async mode, using chunks).

    On the server side -> request contains such info as chunkIndex, fileName, totalFileSize....

    It means: one request for one file.

     

    My questions are:

    1. When do the upload event may have files property with more than one record?

    2. Сan I rely on the fact that "files.length = 1" for async mode using chunks.

    3. Is there are any other options to add my custom field (belongs to file) to request?

     

    I really hope for your help, thanks.

  2. Answer
    Veselin Tsvetanov
    Admin
    Veselin Tsvetanov avatar
    1201 posts

    Posted 04 Nov 2019 Link to this post

    Hi Mike,

    Here are the answers to your questions:

    1. The files collection in the Upload event handler of the widget will have more than one file only if the async.batch option of the widget is set to true. That, however, does not make any sense at all in chunk upload scenario as it will force the widget to send the entire files together with a single request. Having that said, in the chunk upload scenario, the files collection will always contain one item.

    2. Yes, as described above, the files collection will contain only one item.

    3. believe that using the e.data property in the Upload event handler is the proper approach for the scenario in question.

    I hope that the above explains the case. If you have any other questions, please do not hesitate to contact us.

    Regards,
    Veselin Tsvetanov
    Progress Telerik

    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Back to Top