How To: Upload a file to Dropbox with a SmartForm

In this article, you use the Dropbox File SmartObject to upload a file to your Dropbox. This File SmartObject and others are created for each cloud storage feature you activate. These features allow you to integrate K2 with Dropbox, Box, Google Drive, and OneDrive using SmartObjects, and then use these SmartObjects in your K2 solutions. For more information about the cloud storage service type and creating service instances, see Cloud Storage

Using a SmartForm to upload a file to Dropbox

Scenario

Your company uses an online form for customers to request warranty repairs. As part of your form, you want your customers to upload an image showing their damaged item. You need this image uploaded to Dropbox so that your repair engineers can access it.

Steps

In this scenario, you use the Dropbox File SmartObject to create an item view. In the item view, you configure the Upload method with the Path and File parameters.

Setup Steps

The following steps set up the scenario. If you want to skip the setup steps and view the topic step, go to Create a new view using your Dropbox File SmartObject.

  1. Activate the Dropbox feature
    1. See Dropbox Feature Activation for configuration steps

Create a view using the Upload Method

Create and configure a view using the Upload method of the Dropbox File SmartObject. In this scenario, customers upload an image to the Denallix folder.

  1. Create a new view using your Dropbox File SmartObject.
    1. In K2 Designer, navigate to your folder in the Cloud StorageDropbox folder (this name is based on the name you specified during Dropbox feature activation), right click your File SmartObject, and select Design View. If you are not familiar with creating views, see How To: Create an Item View and a List View.
    2. Name the view DropboxUpload_View.
    3. Select a Category for the view. In this example, the category containing the SmartObject is used.
    4. Select Item View.
    5. Click Create to start creating the view.
  2. Configure your view to use the Upload method with the Path and File properties.
    1. Select Create Labels and Controls.
    2. Select to include Path and File layout field names and check the Upload method in the Standard button column.
    3. Your view looks similar to the following image:
  3. Create a new form using your DropboxUpload_View.
    1. On the DropboxUpload_View page, select Design a new Form. If you are not familiar with creating forms, see How To: Create a Form.
    2. Specify DropboxUpload_Form as the Name and Cloud Storage upload form for Dropbox as the Description.
    3. Click Create.
    4. Click Finish to save your form.
  4. Test your form by uploading an image to Dropbox
    1. On the DropboxUpload_Form page in K2 Designer, click Run.
    2. Drag your image onto the File control and specify the Path (you must include the file name and extension of the file in the Path property). In this scenario, you upload a file named repair_needed.jpg to the Denallix folder. Note that you may want to create a rule to change the name of the file before uploading it to Dropbox.
    3. Go to your Denallix folder in Dropbox and confirm that the image is uploaded.
Review

You used the Upload method of the Dropbox File SmartObject to upload an image to a Dropbox folder.