Cloud Storage
Use the cloud storage group of service types to connect K2 to OAuth-based online file services such as Box, Dropbox, Google Drive, and OneDrive.
To enable the cloud storage features, you must log a support ticket with K2 and agree to a disclaimer. To log the ticket, please follow the steps below.
- Run the following SQL script against your K2 database to obtain your K2 environment variables:SELECT
(SELECT DB_NAME()) AS [K2_Database],
(SELECT
DISTINCT LTRIM(RTRIM(REPLACE(fv.FieldValue, '/Runtime/Runtime',''))) + '/identity/token/oauth/2'
FROM Environment.Field f INNER JOIN Environment.FieldValue fv ON fv.FieldId = f.FieldId
WHERE f.IsDefault = 1 AND f.FieldName = 'SmartForms Runtime SSL'
) AS [RedirectUrl],
(SELECT VariableValue
FROM [HostServer].[Configuration]
WHERE VariableToken = '[ENV_ID]'
) AS [EnvironmentId] - Log a support ticket with the following details
Ticket Subject Cloud Storage Activation Problem Description Please activate Cloud Storage for the following environment.
Environment ID: {INSERT your Environment ID}
Redirect URL: {INSERT your Redirect URL}
Database Name: {INSERT your K2 Database Name}Service Type: {INSERT Google Drive, Box, Dropbox, and/or OneDrive}
- The Redirect URL must be secured with SSL (HTTPS).
- The Redirect URL value is case-sensitive - be sure to copy and paste the redirect URL exactly as returned by the SQL query results.
To configure a service instance and create SmartObjects to integrate with these services, see the following feature activation topics:
Cloud storage SmartObjects use OAuth tokens to authenticate with your cloud storage provider. Use the following authentication details to plan the behavior you need in your K2 applications:
- Workflows: When a cloud storage SmartObject method is executed without user context, such as in a SmartObject step in a workflow, the account used during Feature Activation is used to access the cloud storage provider and uses the OAuth token created during Feature Activation. See How To: Use a workflow as an intermediary to upload a file from a form to cloud storage for an example of this approach.
- SmartForms: When a cloud storage SmartObject method is executed with user context, such as in a SmartForm, the person using the form must login with their cloud storage credentials which creates an OAuth token. In this case, they have access to their own personal files and folders. See How To: Upload a file to Google Drive with a SmartForm for an example of this approach.
- If your SmartForm needs the contents of the account used during Feature Activation, every person using the form must login with that account.
- If your SmartForm needs the cloud storage contents of the person using the SmartForm, every person using the form must login with their own account.
In most cases you should use cloud storage SmartObjects methods from a workflow so that the same cloud drive is used. When using cloud storage SmartObjects with SmartForms, you can start a workflow with a button or rule to execute SmartObject methods. Only use a direct cloud storage SmartObject method in a SmartForm if you need a folder or file from the cloud storage account of the person using the SmartForm.
Service Keys (Service Instance Configuration Settings)
Key | Can be modified | Data Type | Sample Value | Notes |
---|---|---|---|---|
Element Type | Yes | Text | dropbox | Optional. A label for the name of the service with which you're integrating. |
Log Method After Duration | Yes | Text | -1 | For internal use only. Used for logging and debugging. |
Service Objects
The cloud storage service types have three service objects: File, Folder, and Service. The example below is from Dropbox, however the same service objects are created for other supported cloud storage services.
File Methods
Method | Notes |
---|---|
Copy | Creates a copy of the file. |
Delete | Deletes the file. |
Download | Downloads the file. In the Path property, specify the destination folder, including the file name and extension of the file you want to download. |
Get info | Gets information about a file, such as file name, description, and size. |
Move | Creates a copy of the file in another folder and deletes the original file. |
Update tags | Overwrites the tag property of the file with the contents of the specified string. |
Upload | Adds a new file. In the Path property, specify the destination folder, including the file name and extension with which to upload the file. (If you only specify a folder, this method will use the folder name as the file name and create the file without an extension.) |
Folder Methods
Method | Notes |
---|---|
Copy | Copies all files in the folder to a new folder. |
Create | Creates a new folder. |
Delete | Deletes a folder and all the files and folders in it. |
Get info | Gets information about a folder, such as folder name and description. |
List contents | Returns a list of the files and folders within this folder. |
Move | Creates a new folder, copies the files and folders into that new folder, then deletes the original folder. |
Update tags | Overwrites the tag property of the folder with the contents of the specified string. This needs to be a valid JSON array string. |
System Methods
Method | Notes |
---|---|
Search | You can search by Path and Keyword. Returns a list of matching file or folder objects. |
SmartObjects
Use the File SmartObject to copy, delete, download, get info, move, update tags, or upload files. Use the Folder SmartObject to copy, create, delete, get info, list contents, move, or update tags on your cloud storage. Use the Service SmartObject to search files and folders on Box, Dropbox, Google Drive, and OneDrive.
See the following topics for examples of using these SmartObjects:
- How To: Upload a file to Google Drive with a SmartForm
- How To: Use a workflow as an intermediary to upload a file from a form to cloud storage
- How To: Download a file from Google Drive and attach it to an Email
- How To: Use the Tree Control to navigate your Google Drive folders
- How To: Upload a file to Dropbox from a form
- How To: Download a file from Dropbox and attach it to an Email
- How To: Use the Tree Control to navigate your Dropbox folders
Considerations
- You should not manually create cloud storage service instances. Use the feature activations to create your instances for: