Bug Description
When uploading a file via gws drive files create --upload with mimeType: "application/vnd.google-apps.document" in --params, the file is uploaded as-is rather than being converted to a native Google Doc.
The Google Drive API supports importing files by setting mimeType in the metadata to the target Google Workspace type (e.g., application/vnd.google-apps.document) while sending the file content with its actual MIME type (e.g., text/html or application/vnd.openxmlformats-officedocument.wordprocessingml.document). This requires a multipart upload where metadata and file content are sent as separate parts.
The CLI appears to do a simple media upload, so the metadata mimeType is either ignored or used as the upload content type — neither of which triggers Drive's conversion.
Steps to Reproduce
# Convert markdown to HTML (or docx via pandoc)
echo "<h1>Hello</h1><p>World</p>" > /tmp/test.html
# Attempt to upload as a Google Doc
gws drive files create \
--params '{"name":"Test Import","mimeType":"application/vnd.google-apps.document"}' \
--upload /tmp/test.html
# Result: file is uploaded as text/html, NOT converted to a Google Doc
# Response shows: "mimeType": "text/html"
# Expected: "mimeType": "application/vnd.google-apps.document"
Same behavior with docx files — they upload as raw application/vnd.openxmlformats... instead of being converted.
Expected Behavior
When mimeType in --params is a Google Workspace type (application/vnd.google-apps.document, application/vnd.google-apps.spreadsheet, etc.) and --upload is provided, the CLI should:
- Use the
--params mimeType as the metadata mimeType (target format)
- Detect the upload file's actual MIME type (from extension or content) for the media part
- Perform a multipart upload so Drive converts the file
Workaround
Upload the file via Google Drive web UI, then right-click > "Open with Google Docs" to trigger conversion manually.
Related Issues
Environment
- gws version: 0.7.0
- OS: macOS (Darwin, aarch64)
Bug Description
When uploading a file via
gws drive files create --uploadwithmimeType: "application/vnd.google-apps.document"in--params, the file is uploaded as-is rather than being converted to a native Google Doc.The Google Drive API supports importing files by setting
mimeTypein the metadata to the target Google Workspace type (e.g.,application/vnd.google-apps.document) while sending the file content with its actual MIME type (e.g.,text/htmlorapplication/vnd.openxmlformats-officedocument.wordprocessingml.document). This requires a multipart upload where metadata and file content are sent as separate parts.The CLI appears to do a simple media upload, so the metadata
mimeTypeis either ignored or used as the upload content type — neither of which triggers Drive's conversion.Steps to Reproduce
Same behavior with docx files — they upload as raw
application/vnd.openxmlformats...instead of being converted.Expected Behavior
When
mimeTypein--paramsis a Google Workspace type (application/vnd.google-apps.document,application/vnd.google-apps.spreadsheet, etc.) and--uploadis provided, the CLI should:--paramsmimeTypeas the metadata mimeType (target format)Workaround
Upload the file via Google Drive web UI, then right-click > "Open with Google Docs" to trigger conversion manually.
Related Issues
--upload-type, which could also solve this if the CLI used it for the media part while keeping--paramsmimeType for metadata.Environment