.. _cloud-example:

#############
Send to Cloud
#############

.. image:: ../../../images/vtfx/cloud_example.png
    :height: 250px
    :align: center

An example showing how to upload a VTFx file to Ceetron Cloud (using Qt). 

**Get the upload ID from the user**

The user needs to provide his/her unique upload ID to upload the file. The user will need an account on 
https://cloud.ceetron.com, so you need to send the user either to the https://cloud.ceetron.com/signup page or 
https://cloud.ceetron.com/login page. From the "My Account" page the user can press the button "Show and copy NN's 
Upload ID" to get the upload ID. You should only ask for this once, and then store it somewhere safe in your app.

The Upload ID is a GUID, e.g.: 765ba418-58ea-4c0a-afd1-fb4ff8f410ee

Pass this to the example from the command prompt 

::

    > sendToCloud.exe -uploadId 'uploadId'

**Export the model to a VTFx file.**

Next, we need to create the VTFx file for upload. In this example we use the same model as in the Minimal Example. 
You should export to a temporary file, which should be deleted after upload.

**Upload the file to Ceetron Cloud.**

Use the following REST API call to upload the file to Ceetron:

API: %https://cloud.ceetron.com/api/v1/models

Params:

-   uploadId: The users' Upload ID. 
-   uploadApp: The name of your app.
-   name: The name of the model. This will become the default name in the My Models page of the user on Ceetron Cloud.

Example:

::

    %https://cloud.ceetron.com/api/v1/models?uploadId=765ba418-58ea-4c0a-afd1-fb4ff8f410ee&uploadApp=My%20App&name=Demo%20Model


.. note::

    The uploadApp and name parameters needs to be percent encoded to form a valid URI

The upload must be done with a "multipart/form-data" HTTPS POST, where the VTFx is sent as a file with the name "vtfx".

::

    Content-Disposition: form-data; name=\"vtfx\"; filename=\"upload.vtfx\"
    Content-Type: application/octet-stream


**QSCMain.cpp**

.. literalinclude:: ../../../../../../EnvisionDesktop/Examples/VTFx/VTFxQtSendToCloud/QSCMain.cpp
    :language: cpp
    :lines: 45-322


**QSCCloudTracker.h**

.. literalinclude:: ../../../../../../EnvisionDesktop/Examples/VTFx/VTFxQtSendToCloud/QSCCloudTracker.h
    :language: cpp
    :lines: 19-97

