Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[harsh: Fix formatting]
Signed-off-by: Harsh Shandilya <msfjarvis@gmail.com>
  • Loading branch information
tomofumi-nakano authored and growtopiajaw committed Nov 25, 2022
1 parent 4f9df5e commit 39e3417
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions drive/upload.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,9 @@ func (self *Drive) uploadFile(args UploadArgs) (*drive.File, int64, error) {
// Chunk size option
chunkSize := googleapi.ChunkSize(int(args.ChunkSize))

// Content type option
contentType := googleapi.ContentType(args.Mime)

// Wrap file in progress reader
progressReader := getProgressReader(srcFile, args.Progress, srcFileInfo.Size())

Expand All @@ -184,7 +187,7 @@ func (self *Drive) uploadFile(args UploadArgs) (*drive.File, int64, error) {
fmt.Fprintf(args.Out, "Uploading %s\n", args.Path)
started := time.Now()

f, err := self.service.Files.Create(dstFile).Fields("id", "name", "size", "md5Checksum", "webContentLink").Context(ctx).Media(reader, chunkSize).Do()
f, err := self.service.Files.Create(dstFile).Fields("id", "name", "size", "md5Checksum", "webContentLink").Context(ctx).Media(reader, chunkSize, contentType).Do()
if err != nil {
if isTimeoutError(err) {
return nil, 0, fmt.Errorf("Failed to upload file: timeout, no data was transferred for %v", args.Timeout)
Expand Down Expand Up @@ -230,6 +233,9 @@ func (self *Drive) UploadStream(args UploadStreamArgs) error {
// Chunk size option
chunkSize := googleapi.ChunkSize(int(args.ChunkSize))

// Content type option
contentType := googleapi.ContentType(args.Mime)

// Wrap file in progress reader
progressReader := getProgressReader(args.In, args.Progress, 0)

Expand All @@ -239,7 +245,7 @@ func (self *Drive) UploadStream(args UploadStreamArgs) error {
fmt.Fprintf(args.Out, "Uploading %s\n", dstFile.Name)
started := time.Now()

f, err := self.service.Files.Create(dstFile).Fields("id", "name", "size", "webContentLink").Context(ctx).Media(reader, chunkSize).Do()
f, err := self.service.Files.Create(dstFile).Fields("id", "name", "size", "webContentLink").Context(ctx).Media(reader, chunkSize, contentType).Do()
if err != nil {
if isTimeoutError(err) {
return fmt.Errorf("Failed to upload file: timeout, no data was transferred for %v", args.Timeout)
Expand Down

0 comments on commit 39e3417

Please sign in to comment.