.. _cartridge.upload:

===============================================================================
Module *cartridge.upload*
===============================================================================

Spread the data across instances in a network-efficient manner.



(**Added** in v2.4.0-43)


-------------------------------------------------------------------------------
Functions
-------------------------------------------------------------------------------


.. _cartridge.upload.upload:

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
upload (data, uri_list)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Spread the data across the cluster. 

For each separate upload, a random `upload_id` is generated. All the
instances try to create `/tmp/<upload_id>` on their side, and those
who succeed act as transmitters.

When the upload finishes, all the instances load the data into the
`inbox` table and the temporary files are cleared. The inbox isn't
garbage-collected automatically. It's the user's responsibility to
clean it up after use.



**Parameters:**

- *data:*  any Lua object.  
- *uri_list:* (`{string,...} <https://www.lua.org/manual/5.1/manual.html#5.4>`_) array of URIs.  

**Returns**:

(`string <https://www.lua.org/manual/5.1/manual.html#5.4>`_) `upload_id` (if at least one upload succeded)


**Or**

(**nil**) 

(`table <https://www.lua.org/manual/5.1/manual.html#5.5>`_) Error description


-------------------------------------------------------------------------------
Tables
-------------------------------------------------------------------------------


.. _cartridge.upload.inbox:

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
inbox
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

The uploaded data. 
``{[upload_id] = data}`` 




