Upload external data

The data management service captures and syncs data from your machines automatically. If you have data from other sources (images from your phone, files on your laptop, or data generated by external processes), you can upload it to Viam directly.

MethodUse caseDeletes local data?Duplicates on re-run?
SDK uploadProgrammatic upload from any computerNoYes
Mobile appQuick image upload from your phone for ML trainingNoNo

For syncing files from a directory on your machine, use the additional_sync_paths option in the data management service. See Sync data from another directory.

Upload with SDKs

Use the Data Client API to upload files programmatically. Unlike the data management service, the FileUploadFromPath method does not delete local files after upload, but it will duplicate data if you run it more than once.

  1. Create an API key for your organization, location, or machine.
  2. Use FileUploadFromPath to upload a file. You must provide a machine part ID to associate the data with.
  3. Run your code once. Running it again uploads the same files a second time.
  4. Check the DATA tab to confirm your data appears.
import asyncio
import os

from viam.rpc.dial import DialOptions, Credentials
from viam.app.viam_client import ViamClient

# Configuration constants – replace with your actual values
API_KEY = ""  # API key, find or create in your organization settings
API_KEY_ID = ""  # API key ID, find or create in your organization settings
ORG_ID = ""  # Organization ID, find or create in your organization settings
PART_ID = ""  # Part ID of machine part that should be associated with the data
FILE_PATH = "file.txt"  # Path to the file to upload

async def connect() -> ViamClient:
    dial_options = DialOptions(
      credentials=Credentials(
        type="api-key",
        # Replace "<API-KEY>" (including brackets) with your machine's API key
        payload=API_KEY,
      ),
      # Replace "<API-KEY-ID>" (including brackets) with your machine's
      # API key ID
      auth_entity=API_KEY_ID
    )
    return await ViamClient.create_from_dial_options(dial_options)

async def main():
    async with await connect() as viam_client:
        data_client = viam_client.data_client

        binary_data_id = await data_client.file_upload_from_path(
          # The ID of the machine part the file should be associated with
          part_id=PART_ID,
          # Any tags you want to apply to this file
          tags=["uploaded"],
          # Path to the file
          filepath=FILE_PATH
        )


if __name__ == '__main__':
    asyncio.run(main())
package main

import (
	"context"
	"os"

	"go.viam.com/rdk/app"
	"go.viam.com/rdk/logging"
)

// Configuration constants – replace with your actual values
var (
	API_KEY     = "" // API key, find or create in your organization settings
	API_KEY_ID  = "" // API key ID, find or create in your organization settings
	ORG_ID      = "" // Organization ID, find or create in your organization settings
	PART_ID     = "" // Part ID of machine part that should be associated with the data
	FILE_PATH   = "file.txt" // Path to the file to upload
)

func main() {
    logger := logging.NewDebugLogger("client")
	ctx := context.Background()

	viamClient, err := app.CreateViamClientWithAPIKey(
		ctx, app.Options{}, API_KEY, API_KEY_ID, logger)
	if err != nil {
		logger.Fatal(err)
	}
	defer viamClient.Close()

	dataClient := viamClient.DataClient()

	binaryDataID, err := dataClient.FileUploadFromPath(
		ctx,
		PART_ID,
		FILE_PATH,
		&app.FileUploadOptions{
			Tags: []string{"uploaded"},
		},
	)
	if err != nil {
		logger.Fatal(err)
	}
}

Upload images with the mobile app

The Viam mobile app lets you upload images directly from your phone, bypassing the normal capture and sync process. This is useful for quickly collecting training images for machine learning models.

Install the app from the App Store or Google Play if you haven’t already.

  1. In the app, select an organization, then tap Locations and navigate to the machine you want the data associated with.
  2. Tap in the upper right corner, then tap Upload Images.
  3. Select the images you want to upload and tap Add.

Uploaded images are associated with the machine part you selected but not with a specific component or method.

Next steps

If you uploaded data for machine learning, continue to create a dataset.