Skip to main content

How to Upload Input Files and Read Them from Your Application

Put a data file into the Signaloid Cloud Storage and open it by path from a program running on the Signaloid Cloud Compute Engine.

Every account includes the Signaloid Cloud Storage, so this is the shortest path from a file on your computer to a file your program can read. To read a bucket you already own in AWS instead, see How to Connect an AWS S3 Bucket.

Upload the file

Open the Data and Sensors page from the sidebar and find the Signaloid Cloud Storage card in the Data Sources section. It carries two buttons:

  • Upload Files opens the Choose files to upload dialog directly. Destination is required and starts empty, so type the path you want before Upload becomes available.
  • View Files opens the file browser, where the Upload action on a directory row opens the same dialog with Destination already set to that directory. Use it to avoid typing the path, or to create the directory first.

The file browser is also where you check what a run wrote and download the results. Figure 1 shows previewing and downloading a file in Signaloid/example-loadDistFromFile/, the directory the default Code Playground program reads from. You can also create directories, copy paths, and delete files from the browser. The Signaloid Cloud Storage reference describes each action.

Figure 1. Previewing a text file in the read-only viewer and downloading a file from the Signaloid Cloud Storage.

Mount the Storage on the run

A data source is invisible to your program until it is mounted, the same way a server or a personal computer mounts a filesystem. The mount location you choose becomes the start of the path your code opens.

Mount it from the Code Playground toolbar for a Code Playground run, or from the Mount Data Source button on the card of a connected repository.

Every run already mounts your Signaloid Cloud Storage at sd0/ by default, so a file uploaded to the storage root is reachable at sd0/<filename> without changing anything. Set a mount location of your own only when you want a different prefix.

Read the file from your code

With the storage mounted at mountDir, your program opens files underneath that path:

FILE * fp = fopen("mountDir/myInputFile.csv", "r");

Writing works the same way, provided the source grants write permission:

FILE * fp = fopen("mountDir/myNewFile.txt", "w");

The default Code Playground program is a worked example of this. It reads a distribution from sd0/Signaloid/example-loadDistFromFile/example.csd. Run Your First Program walks through that program end to end.

Next steps