title: Split and copy a file from a bucket to another bucket, without downloading it locally
body: <p>I'd like to <strong>split</strong> and copy a huge file from a bucket (<code>gs://$SRC_BUCKET/$MY_HUGE_FILE</code>) to another bucket (<code>gs://$DST_BUCKET/</code>), but <strong>without downloading the file locally</strong>. I expect to do this using only <code>gsutil</code> and shell commands.</p>
  
  <p>I'm looking for something with the same final behaviour as the following commands : </p>
  
  <pre><code>gsutil cp gs://$SRC_BUCKET/$MY_HUGE_FILE my_huge_file_stored_locally
  
  split -l 1000000 my_huge_file_stored_locally a_split_of_my_file_
  
  gsutil -m mv a_split_of_my_file_* gs://$DST_BUCKET/
  </code></pre>
  
  <p>But, because I'm executing these actions on a Compute Engine VM with limited disk storage capacity, getting the huge file locally is not possible (and anyway, it seems like a waste of network bandwidth).</p>
  
  <p>The file in this example is split by number of lines (<code>-l 1000000</code>), but I will accept answers if the split is done by number of bytes.</p>
  
  <p>I took a look at the docs about <a href="https://cloud.google.com/storage/docs/streaming#streaming_uploads_and_downloads_using_gsutil" rel="nofollow noreferrer">streaming uploads and downloads using gsutil</a> to do something like :</p>
  
  <pre><code>gsutil cp gs://$SRC_BUCKET/$MY_HUGE_FILE - | split -1000000 | ...
  </code></pre>
  
  <p>But I can't figure out how to upload split files directly to <code>gs://$DST_BUCKET/</code>, without creating them locally (creating temporarily only 1 shard for the transfer is OK though).</p>