How To: Upload a file to Google Drive with a SmartForm
In this article, you use the Google Drive File SmartObject to upload a file to your Google Drive. 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 Google Drive
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 Google Drive so that your repair engineers can access it.
Steps
In this scenario, you use the Google Drive 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 Google Drive File SmartObject.
-
Activate the Google Drive feature
- See Google Drive Feature Activation for configuration steps
Create a view using the Upload Method
Create and configure a view using the Upload method of the Google Drive File SmartObject. In this scenario, customers upload an image to the Denallix folder.
-
Create a new view using your Google Drive File SmartObject.
- In K2 Designer, navigate to your folder in the Cloud Storage > Google Drive folder (this name is based on the name you specified during Google Drive 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.
- Name the view GoogleDrive_Upload_View.
- Select a Category for the view. In this example, the category containing the SmartObject is used.
- Select Item View.
- Click Create to start creating the view.
- In K2 Designer, navigate to your folder in the Cloud Storage > Google Drive folder (this name is based on the name you specified during Google Drive 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.
- Configure your view to use the Upload method with the Path and File properties.
- Select Create Labels and Controls.
- Select to include Path and File layout field names and check the Upload method in the Standard button column.
- Your view looks similar to the following image:
- Select Create Labels and Controls.
- Create a new form using your GoogleDrive_Upload_View.
- On the GoogleDrive_Upload_View page, select Design a new Form.
If you are not familiar with creating forms, see How To: Create a Form.
- Specify GoogleDrive_Upload_Form as the Name and Cloud Storage upload for Google Drive as the Description.
- Click Create.
- Click Finish to save your form.
- On the GoogleDrive_Upload_View page, select Design a new Form.
If you are not familiar with creating forms, see How To: Create a Form.
- Test your form by uploading an image to Google Drive
- On the GoogleDrive_Upload_Form page in K2 Designer, click Run.
- 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 Google Drive.
- Go to your Denallix folder in Google Drive and confirm that the image is uploaded.
- On the GoogleDrive_Upload_Form page in K2 Designer, click Run.
Review
You used the Upload method of the Google Drive File SmartObject to upload an image to a Google Drive folder.