odeke-em / drive

Google Drive client for the commandline
Apache License 2.0
6.69k stars 427 forks source link

Push flag "-convert" has no effect #232

Open Andrew-Dickinson opened 9 years ago

Andrew-Dickinson commented 9 years ago

According to the readme documentation, the "convert" flag is supposed to convert a file to its native google doc format. It seems to have no effect when used with the following xls file:

https://drive.google.com/file/d/0B_KcvpELW9SYNVBmM1JiOG5rQzQ/view?usp=sharing

Or its xlsx equivalent: https://drive.google.com/file/d/0B_KcvpELW9SYcnhYR01oVm15aXM/view?usp=sharing

The flag seems to have no effect in either case. What am I doing wrong?

odeke-em commented 9 years ago

Hello again @smarthimandrew. Thank you for reporting this. I'll take a look at it in about 9 hours when I get back home.

odeke-em commented 9 years ago

As far as I can investigate, the flag is correctly passed into the Google API client and even sent well with the URL parameters. I'll check with the team working on the API client if there is anything more needed.

canpolat commented 9 years ago

Hi,

Any news on this? I observe similar behavior with a CSV file of mine. It just uploads the file with .csv extension and Drive thinks it's a .doc (it tries to open it with Google Documents).

Andrew-Dickinson commented 9 years ago

Nope. I just used a different approach for my project. It would be nice to have this fixed though. On Jul 18, 2015 3:29 PM, "Eren Inan Canpolat" notifications@github.com wrote:

Hi,

Any news on this? I observe similar behavior with a CSV file of mine. It just uploads the file with .csv extension and Drive thinks it's a .doc (it tries to open it with Google Documents).

— Reply to this email directly or view it on GitHub https://github.com/odeke-em/drive/issues/232#issuecomment-122585540.

canpolat commented 9 years ago

In my use case I couldn't find a way around it. I really need it converted. So, here is some more input.

I have a CSV file named "data". Here is what happens when I push it to Google Drive:

Case 1:

drive push -quiet data

Google Drive thinks this is a plain text file. So it offers me to open the file with StackEdit, Drive Notepad, etc.

Case 2:

When I issue any of the following commands:

drive push -quiet data.csv   # Changed the filename to test it out
drive push -quiet -coerced-mime csv data

Google Drive understands that it is a CSV file and offers to open it via Drive Notepad and/or Sheets.

Case 3:

When I try the following two commands:

drive push -quiet -convert data.csv
drive push -quiet -convert -coerced-mime csv data

Both the file icon and the applications offered to open the file suggest that Google Drive has converted the file into Google Docs (not Sheets) format.

Case 4:

I converted the file to ODS locally and:

drive push -quiet -convert data.ods

This one was weird. It did not convert the file and didn't even offer to open it with Sheets (Zoho Sheet was an option, though). Apparently Google Drive doesn't support ODS.

All in all, in some cases, -convert converts, but only to Google Docs and never to Sheets.

@odeke-em, you already said that this is not a problem on drive's side (unless your investigation showed otherwise); should I report this problem somewhere else (if so, where)?

canpolat commented 9 years ago

Ping!

I still observe that .CSV files are converted to Google Document files instead of Sheets. @odeke-em from what you said earlier, it's clearly not a drive issue. But you are definitely closer to the Google Drive team than I am. So I wonder if there is another way of attracting their attention? Should I submit a ticket elsewhere (if so, where)? This issue really disrupts my workflow (introduces a few manual steps to an otherwise automated set up), if I sound insistent, that's the only reason :)

odeke-em commented 9 years ago

Oops sorry for the late reply @canpolat, my apologies I didn't mean to ignore this :) So I think I might try out something to patch this up for you, but that will be in about 8 hours as I have an event this evening :( but surely in the next 24 hours I'll ping you. For sure, I can consult with them and bring this issue to their attention. Thank you for the investigation, and my apologies again for the late reply plus the bug.

odeke-em commented 9 years ago

Hello @canpolat, so I got some time before heading out. One thing is as you'd probably noticed is that even uploading csv files via the web UI will set the mimeType to 'text/csv'. I have started a PR to escape this in a way, please see https://github.com/odeke-em/drive/pull/357.

canpolat commented 9 years ago

@odeke-em No worries. If this was actually a problem on drive I'm pretty sure it would have been solved by now. But dependencies are tricky :)

odeke-em commented 9 years ago

Hello folks, as seen in @canpolat's investigation as well as from PR https://github.com/odeke-em/drive/pull/357, when csv files get converted or even uploaded, their mimeType is text/csv and this is from Google Drive itself. Now what you can do is instead of setting --convert when uploading csv and tsv files is just upload it plainly as

$ drive push csvfiles.csv

This will upload it as a spreadsheet, when you use the Google Drive Web UI viewer it will create a Google Sheet directly from it but the caveat is that create a duplicate file.

tom-saunders commented 9 years ago

I am coming at this from the opposite side - I don't want documents converted when they are pushed. Is there some way this can be achieved? I can open a separate issue to cover this.

(If it's relevant in my case I have plain text files which I don't want coercing into document files - I'd rather they stay as plain text. It's also very possible I'm just misunderstanding the documentation.)

odeke-em commented 9 years ago

Hello again @tom-saunders, --convert is an optional flag. By default no documents are converted so yours is the common case, no need for alarm :)

tom-saunders commented 9 years ago

It appears that uploading via the web client vs drive does something slightly different - files uploaded through drive are readable online while similar files uploaded through web client are not. This was unexpected, but doesn't appear to have caused any harm so it's no issue.

canpolat commented 8 years ago

I filed an issue at the Google Apps APIs: https://code.google.com/a/google.com/p/apps-api-issues/issues/detail?id=4198

Please star it so that it gets prioritized.

Edit: I could reproduce the issue via Google's own file upload example, so it must be an API issue.

odeke-em commented 8 years ago

Awesome thank you @canpolat for creating that! Am definitely going to star it too.

odeke-em commented 8 years ago

I've tweeted https://twitter.com/odeke_et/status/678145002174836736, please share with your friends so that we can get this starred and looked at.