@@ -1496,11 +1496,29 @@ func (w *gRPCWriter) startResumableUpload() error {
14961496 if err != nil {
14971497 return err
14981498 }
1499+ req := & storagepb.StartResumableWriteRequest {
1500+ WriteObjectSpec : spec ,
1501+ CommonObjectRequestParams : toProtoCommonObjectRequestParams (w .encryptionKey ),
1502+ }
1503+ // TODO: Currently the checksums are only sent on the first message
1504+ // of the stream, but in the future, we must also support sending it
1505+ // on the *last* message of the stream (instead of the first).
1506+ if w .sendCRC32C {
1507+ req .ObjectChecksums = & storagepb.ObjectChecksums {
1508+ Crc32C : proto .Uint32 (w .attrs .CRC32C ),
1509+ }
1510+ }
1511+ if len (w .attrs .MD5 ) != 0 {
1512+ if cs := req .GetObjectChecksums (); cs == nil {
1513+ req .ObjectChecksums = & storagepb.ObjectChecksums {
1514+ Md5Hash : w .attrs .MD5 ,
1515+ }
1516+ } else {
1517+ cs .Md5Hash = w .attrs .MD5
1518+ }
1519+ }
14991520 return run (w .ctx , func () error {
1500- upres , err := w .c .raw .StartResumableWrite (w .ctx , & storagepb.StartResumableWriteRequest {
1501- WriteObjectSpec : spec ,
1502- CommonObjectRequestParams : toProtoCommonObjectRequestParams (w .encryptionKey ),
1503- })
1521+ upres , err := w .c .raw .StartResumableWrite (w .ctx , req )
15041522 w .upid = upres .GetUploadId ()
15051523 return err
15061524 }, w .settings .retry , w .settings .idempotent , setRetryHeaderGRPC (w .ctx ))
@@ -1587,23 +1605,6 @@ func (w *gRPCWriter) uploadBuffer(recvd int, start int64, doneReading bool) (*st
15871605 req .CommonObjectRequestParams = toProtoCommonObjectRequestParams (w .encryptionKey )
15881606 }
15891607
1590- // TODO: Currently the checksums are only sent on the first message
1591- // of the stream, but in the future, we must also support sending it
1592- // on the *last* message of the stream (instead of the first).
1593- if w .sendCRC32C {
1594- req .ObjectChecksums = & storagepb.ObjectChecksums {
1595- Crc32C : proto .Uint32 (w .attrs .CRC32C ),
1596- }
1597- }
1598- if len (w .attrs .MD5 ) != 0 {
1599- if cs := req .GetObjectChecksums (); cs == nil {
1600- req .ObjectChecksums = & storagepb.ObjectChecksums {
1601- Md5Hash : w .attrs .MD5 ,
1602- }
1603- } else {
1604- cs .Md5Hash = w .attrs .MD5
1605- }
1606- }
16071608 }
16081609
16091610 err = w .stream .Send (req )
0 commit comments