Sending data to a GCS bucket
Connecting to a GCS bucket
Section titled “Connecting to a GCS bucket”To send data to a GCS bucket, you need to execute connect send gcs
with following mandatory parameter:
--bucket
then the GCS bucket name
Depending on the type of authentication you need to either use --auth-json
for key based authentication
or use the service account assigned to the instance (if the server is running on GCP).
To use JSON key for the authentication you need to provide:
--auth-json
then the path to the file containing the auth JSON
To authenticate with Application Default Credentials (ADC) you need to
set GOOGLE_APPLICATION_CREDENTIALS
environment variable that points to the key file.
export GOOGLE_APPLICATION_CREDENTIALS="/path/to/key-file.json"
Then you can omit providing the key file as it will be obtained from the environment variable.
For user credentials, ADC can be set by running Following
$ gcloud auth application-default login
Once authenticated you can connect without specifying the JSON key.
Sending single file to a GCS bucket
Section titled “Sending single file to a GCS bucket”To send a single file to a GCS bucket you should use
--file
followed by the file name to be sent
Following command will send file1.zip
file to a GCS bucket my-gcs-bucket
using JSON key for the authentication.
$ connect send gcs --file file1.zip --bucket my-gcs-bucket --auth-json /path/to/key-file.json2025/06/03 13:50:14 INFO Sending files to gcs://my-gcs-bucket/2025/06/03 13:50:14 INFO Files to send: count=1[file1.zip] 10.00 MiB / 10.00 MiB done
Sending multiple files to a GCS bucket
Section titled “Sending multiple files to a GCS bucket”If you’d like to send multiple files to a GCS bucket you need to specify either file mask or file regular expression for the files.
--file-mask
a file mask--file-regex
regular expression
This will cause all files that match a certain mask or pattern to be sent. You can also provide an optional source folder that contain the files to be sent:
-s, --src-folder
If you don’t provide the source folder files will be sent from the current folder.
Following command will send all .zip
files from /data
folder to a GCS bucket my-gcs-bucket
using JSON key for the authentication.
$ connect send gcs --file-mask "*.zip" -s /data --bucket my-gcs-bucket --auth-json /path/to/key-file.json2025/06/03 13:59:22 INFO Sending files to gcs://my-gcs-bucket/2025/06/03 13:59:22 INFO Files to send: count=3[file3.zip] 10.00 MiB / 10.00 MiB done[file2.zip] 10.00 MiB / 10.00 MiB done[file1.zip] 10.00 MiB / 10.00 MiB done
You can also provide an optional destination folder on GCS bucket:
-d, --dst-folder
If you don’t provide the destination folder files will be sent to the “home folder” of the GCS bucket (top-level of the GCS bucket).
In below example all .zip
files from /data
folder will be sent to remote
folder of GCS bucket my-gcs-bucket
using JSON key for the authentication.
$ connect send gcs --file-regex ".+\.zip" -s /data -d remote --bucket my-gcs-bucket --auth-json /path/to/key-file.json2025/06/03 14:03:59 INFO Sending files to gcs://my-gcs-bucket/remote2025/06/03 14:03:59 INFO Files to send: count=3[file3.zip] 10.00 MiB / 10.00 MiB done[file2.zip] 10.00 MiB / 10.00 MiB done[file1.zip] 10.00 MiB / 10.00 MiB done
Sending files in batch mode to a GCS bucket
Section titled “Sending files in batch mode to a GCS bucket”When using the application in batch or non-interactive mode, such as in a script or scheduler, you should disable the progress bar by using
--batch
to send files in batch mode
Following command will send all .zip
files from the /data
folder to the remote
folder of GCS bucket my-gcs-bucket
using JSON key for the authentication.
$ connect send gcs --file-mask "*.zip" -s /data -d remote --batch --bucket my-gcs-bucket --auth-json /path/to/key-file.json2025/06/03 14:05:37 INFO Sending files to gcs://my-gcs-bucket/remote2025/06/03 14:05:37 INFO Files to send: count=32025/06/03 14:05:37 INFO Transferring file=/data/file3.zip targetFolder=remote2025/06/03 14:05:39 INFO File transferred successfully bytesTransferred=10485760 duration=1s706ms transferRate=5.86MB/s file=/data/file3.zip targetFolder=remote2025/06/03 14:05:39 INFO Transferring file=/data/file2.zip targetFolder=remote2025/06/03 14:05:41 INFO File transferred successfully bytesTransferred=10485760 duration=1s713ms transferRate=5.84MB/s file=/data/file2.zip targetFolder=remote2025/06/03 14:05:41 INFO Transferring file=/data/file1.zip targetFolder=remote2025/06/03 14:05:43 INFO File transferred successfully bytesTransferred=10485760 duration=1s886ms transferRate=5.30MB/s file=/data/file1.zip targetFolder=remote
Sending files from scheduler to a GCS bucket
Section titled “Sending files from scheduler to a GCS bucket”When running the application from a scheduler, it’s recommended to ensure only one instance operates on a specific folder. It’s possible to configure the application to create a flag file at startup and delete it upon completion. If another instance tries to start while one is already running, it will detect the flag file and exit. This approach ensures that only one instance of the application runs at any given time. To do that use
--flag
path to the flag file
Following command will send all .zip
files from the /data
folder to the remote
folder of GCS bucket my-gcs-bucket
using JSON key for the authentication and /tmp/flag1
as a flag file.
Mind that we are using batch mode as it’s required for the application to run correctly from script or scheduler.
$ connect send gcs --flag /tmp/flag1 --batch --file-mask "*.zip" -s /data -d remote --bucket my-gcs-bucket --auth-json /path/to/key-file.json2025/06/03 14:07:00 INFO Using flag file: /tmp/flag12025/06/03 14:07:00 INFO Sending files to gcs://my-gcs-bucket/remote2025/06/03 14:07:00 INFO Files to send: count=32025/06/03 14:07:00 INFO Transferring file=/data/file3.zip targetFolder=remote2025/06/03 14:07:02 INFO File transferred successfully bytesTransferred=10485760 duration=2s326ms transferRate=4.30MB/s file=/data/file3.zip targetFolder=remote2025/06/03 14:07:02 INFO Transferring file=/data/file2.zip targetFolder=remote2025/06/03 14:07:04 INFO File transferred successfully bytesTransferred=10485760 duration=1s717ms transferRate=5.82MB/s file=/data/file2.zip targetFolder=remote2025/06/03 14:07:04 INFO Transferring file=/data/file1.zip targetFolder=remote2025/06/03 14:07:06 INFO File transferred successfully bytesTransferred=10485760 duration=1s735ms transferRate=5.76MB/s file=/data/file1.zip targetFolder=remote2025/06/03 14:07:06 INFO Removing flag file: /tmp/flag1
Sending files in parallel to a GCS bucket
Section titled “Sending files in parallel to a GCS bucket”To speed up file delivery you can send files simultaneously. Application will then send files using multiple sessions. To specify number of concurrent GCS sessions use:
--parallel
number of GCS sessions
Following command will send all .zip
files from the /data
folder to the remote
folder of GCS bucket my-gcs-bucket
using JSON key for the authentication and 3
parallel sessions.
$ connect send gcs --file-mask "*.zip" -s /data -d remote --batch --parallel 3 --bucket my-gcs-bucket --auth-json /path/to/key-file.json2025/06/03 14:08:40 INFO Sending files to gcs://my-gcs-bucket/remote2025/06/03 14:08:40 INFO Files to send: count=32025/06/03 14:08:40 INFO Transferring file=/data/file1.zip targetFolder=remote2025/06/03 14:08:40 INFO Transferring file=/data/file2.zip targetFolder=remote2025/06/03 14:08:40 INFO Transferring file=/data/file3.zip targetFolder=remote2025/06/03 14:08:41 INFO File transferred successfully bytesTransferred=10485760 duration=1s701ms transferRate=5.88MB/s file=/data/file1.zip targetFolder=remote2025/06/03 14:08:41 INFO File transferred successfully bytesTransferred=10485760 duration=1s731ms transferRate=5.78MB/s file=/data/file2.zip targetFolder=remote2025/06/03 14:08:41 INFO File transferred successfully bytesTransferred=10485760 duration=1s785ms transferRate=5.60MB/s file=/data/file3.zip targetFolder=remote
Sending files in sequence to a GCS bucket
Section titled “Sending files in sequence to a GCS bucket”If you don’t specify the --parallel
option then files will be sent using single session in the same order as they showed up on the filesystem (oldest files first).
Action after file is delivered to a GCS bucket
Section titled “Action after file is delivered to a GCS bucket”After file is successfully delivered to remote location it’s possible to remove it from source or move it to a different folder at the source system.
--delete
delete a file after it’s delivered--move-folder
target folder to move the file after it’s delivered
Following command will send all .zip
files from the /data
folder to the remote
folder of GCS bucket my-gcs-bucket
using JSON key for the authentication and 3
parallel sessions and then move the files to /archive
at the source system.
$ connect send gcs --file-mask "*.zip" -s /data -d remote --batch --parallel 3 --bucket my-gcs-bucket --move-folder /archive --auth-json /path/to/key-file.json2025/06/03 14:09:35 INFO Sending files to gcs://my-gcs-bucket/remote2025/06/03 14:09:35 INFO Files to send: count=32025/06/03 14:09:35 INFO Transferring file=/data/file2.zip targetFolder=remote2025/06/03 14:09:35 INFO Transferring file=/data/file3.zip targetFolder=remote2025/06/03 14:09:35 INFO Transferring file=/data/file1.zip targetFolder=remote2025/06/03 14:09:37 INFO File moved to folder folder=/archive file=/data/file1.zip2025/06/03 14:09:37 INFO File transferred successfully bytesTransferred=10485760 duration=1s770ms transferRate=5.65MB/s file=/data/file1.zip targetFolder=remote2025/06/03 14:09:37 INFO File moved to folder folder=/archive file=/data/file2.zip2025/06/03 14:09:37 INFO File transferred successfully bytesTransferred=10485760 duration=1s805ms transferRate=5.54MB/s file=/data/file2.zip targetFolder=remote2025/06/03 14:09:37 INFO File moved to folder folder=/archive file=/data/file3.zip2025/06/03 14:09:37 INFO File transferred successfully bytesTransferred=10485760 duration=2s19ms transferRate=4.95MB/s file=/data/file3.zip targetFolder=remote
Following command will send all .zip
files from the /data
folder to the remote
folder of GCS bucket my-gcs-bucket
using JSON key for the authentication and 3
parallel sessions and then removes the files from source.
$ connect send gcs --file-mask "*.zip" -s /data -d remote --batch --parallel 3 --bucket my-gcs-bucket --delete --auth-json /path/to/key-file.json2025/06/03 14:22:19 INFO Sending files to gcs://my-gcs-bucket/remote2025/06/03 14:22:19 INFO Files to send: count=32025/06/03 14:22:19 INFO Transferring file=/data/file1.zip targetFolder=remote2025/06/03 14:22:19 INFO Transferring file=/data/file2.zip targetFolder=remote2025/06/03 14:22:19 INFO Transferring file=/data/file3.zip targetFolder=remote2025/06/03 14:22:21 INFO File deleted file=/data/file1.zip2025/06/03 14:22:21 INFO File transferred successfully bytesTransferred=10485760 duration=1s744ms transferRate=5.73MB/s file=/data/file1.zip targetFolder=remote2025/06/03 14:22:21 INFO File deleted file=/data/file3.zip2025/06/03 14:22:21 INFO File transferred successfully bytesTransferred=10485760 duration=1s824ms transferRate=5.48MB/s file=/data/file3.zip targetFolder=remote2025/06/03 14:22:22 INFO File deleted file=/data/file2.zip2025/06/03 14:22:22 INFO File transferred successfully bytesTransferred=10485760 duration=2s315ms transferRate=4.32MB/s file=/data/file2.zip targetFolder=remote
All GCS Send Options
Section titled “All GCS Send Options”Usage: connect send gcs [command] [flags]
Flags: --auth-json string GCS authentication json file --bucket string GCS bucket
Global Flags: --batch No progress bars --delete Delete files after successful send -d, --dst-folder string Folder where files should be sent --file string File name to be sent --file-mask string File mask to filter files for sending --file-regex string File regex to filter files for sending --flag string Flag file name --from-mail string From mail used to send notifications (only in batch mode) --godebug Turns on debug mode --help Prints help for the command --log-format string Log output format: text|json (default "text") --mail-format string Mail format [text|html] (only in batch mode) (default "plain") --move-folder string Folder to move files after successful send --no-color Do not use colors in logs --parallel uint Number of sessions used to send files (default 1) --quiet Makes no output -s, --src-folder string Folder containing files to be sent (default "./") --to-mail-failure strings Email list to send failure notification (only in batch mode) --to-mail-success strings Email list to send success notification (only in batch mode)
Errors
Section titled “Errors”Please check here for information on the possible errors.