1

I am developing a simple web app to upload stuff to google bucket. I am using child_process.exec method to fire the upload command, the command is as follows,

child = exec(command, function (error,
stdout, stderr) {
console.log('stdout: ' + stdout);
console.log('stderr: ' + stderr);
});

command = /Users/nachiketjoshi/google-cloud-sdk/bin/bootstrapping/gsutil.py cp -r /Users/nachiketjoshi/Desktop/shell-upload-sample gs://bucket-name

The problem I am facing is that the console output in the web app shows the entire status after the file is uploaded.

I want to see the output just like the command line utility shows while uploading that is with a status bar and percentage and everything.

Currently, with above child_process I can see something as follows on the web app console.

[2 files][ 10.0 MiB/ 30.0 MiB]  664.3 KiB/s                                   
\
\ [2 files][ 10.5 MiB/ 30.0 MiB]  585.3 KiB/s                                   
|
| [2 files][ 11.0 MiB/ 30.0 MiB]  525.7 KiB/s                                   
/
/ [2 files][ 11.6 MiB/ 30.0 MiB]  476.7 KiB/s                                   

[2 files][ 12.1 MiB/ 30.0 MiB]  439.3 KiB/s                                   
\
|
| [2 files][ 12.8 MiB/ 30.0 MiB]  511.6 KiB/s                                   
/
/ [2 files][ 13.9 MiB/ 30.0 MiB]  595.3 KiB/s                                   

[2 files][ 14.7 MiB/ 30.0 MiB]  660.8 KiB/s                                   
\
\ [2 files][ 15.2 MiB/ 30.0 MiB]  538.9 KiB/s                                   
|
/
/ [2 files][ 15.7 MiB/ 30.0 MiB]  424.6 KiB/s                                   

[2 files][ 16.2 MiB/ 30.0 MiB]  339.7 KiB/s                                   
\
\ [2 files][ 16.7 MiB/ 30.0 MiB]  408.2 KiB/s                                   
|
/
/ [2 files][ 17.2 MiB/ 30.0 MiB]  427.0 KiB/s                                   

\
\ [2 files][ 18.0 MiB/ 30.0 MiB]  415.3 KiB/s                                   
|
/
/ [2 files][ 18.5 MiB/ 30.0 MiB]  394.7 KiB/s                                   

\
\ [2 files][ 19.0 MiB/ 30.0 MiB]  403.4 KiB/s                                   
|
| [2 files][ 19.5 MiB/ 30.0 MiB]  371.9 KiB/s                                   
/
/ [2 files][ 20.3 MiB/ 30.0 MiB]  433.6 KiB/s                                   

Operation completed over 3 objects/30.0 MiB.

What exactly does above output mean?

What changes should I make so that I can see the proper 'live output' on my web console?

Nachiket Joshi
  • 101
  • 2
  • 13

1 Answers1

0

I am not sure you can do what you want using gsutil (I don't think you can capture the output), however this answer (using the cloud storage API instead of gsutil) may be what you are looking for.

oclipa
  • 382
  • 2
  • 12
  • I don't want to upload it by using the API. I want to do it by the gsutil. My webapp first installs gsutil on the client machine, sets environment variables, authorizes the service account for the bucket and then uploads the files to the same bucket. The only thing that is remaining is this upload status.... – Nachiket Joshi Dec 05 '17 at 19:17
  • @NachiketJoshi Yes, I understand, however I have investigated this myself and it doesn't not appear to be possible (however I would be glad for someone to prove me wrong). As it stands, it appears the only way to report on GCS transfer status (of individual transfers) is to use the API rather than gsutil. – oclipa Dec 07 '17 at 06:40