Google Drive's "Download zip" adds .txt extension to plain text files - google-drive-api

While experimenting with Google Drive SDK, I noticed a possibly unwanted behaviour of the Google Drive web interface.
When downloading an entire folder as a zip file, some files within that folder with MIME text/plain appear in the zip with added extension .txt, even if their extension is different on Drive.
For example, I had some .conf and .asc files, which ended being .conf.txt and .asc.txt in the resulting compressed archive, respectively.
The issue seems to exist only when using the "Download zip" feature: if the files are downloaded from the web interface one by one or using the SDK the extension is the original, as expected.

For Windows, you can download all your files from Google Drive, but instead of using the browser,
Go to https://www.google.com/drive/download/
Install Google Drive Sync executable
Log into whichever Google account that has your files
Open Windows Explorer and find where your Google Drive is mapped. You should see an icon like the following:
Double-click the Google Drive icon and navigate to the folder you wish to download. You should see links to your Google files, but non-Google files are downloaded and sync'ed with Google Drive Sync like the following:
Right-click to get the context menu and select the compression program. E.g., I have 7-zip installed, so I selected 7-Zip > Add to "your_file.zip"
This will compress the files without adding any weird file extensions. I haven't tried this on Mac or other compression programs. I believe this should work for any file extension since the files are downloaded to your hard drive.
Note, you can select which folders to sync, in case you have folders that were shared with you. This prevents huge downloads, large sync times and allows you to only download and sync only what you need.
Hope that helps.

The same situation with ZIP archives. I use the usual ZIP scheme to store files, but with a different extension *.tec. Before downloading the archive, Google rigidly renames the files to *.tec.zip!
I don't see any solution other than to programmatically check the files for the "zip" extension and rename them before opening. Of course, it's a problem that my product has to fix Google's bugs, but there it is...

Related

Getting files from Google Drive "Computers" into Google Colab

I need to make use of Google Colab's GPUs, but also need to constantly upload new files and make slight adjustments to other files so I used Google's Backup/Sync tools to automatically stream a folder from my local machine into Google Drive so that new/updated/deleted files are automatically loaded. The problem is that I can't figure out how to get the data from the computer into Colab.
Most solutions I've seen on stack overflow use
from google.colab import drive
drive.mount("/content/gdrive",force_remount=True)
The problem with this is that upon doing this, inside of /content/gdrive there is only the folder "My Drive", whereas the files from my computer get saved in a different area "Computers/My Computer/". Thus these files aren't accessible using this method. Is there a way in Colab to be able to access the content in Computers/My Computer/ ?
The only other solutions I have seen have some code inside of Colab allowing you to directly upload files, which doesn't suit my purposes since I don't want to have to manually upload files every time.
In Colab, you might not be able to access any folder or files other than "/content/drive/My Drive". For example, you are not able to access files under '/content/drive/Computers/My Laptop/Project_R_Py/lib_py'.
You can simply go to google drive, right click that folder ("lib_py") and choose "Add Shortcut to Drive". After that you should be able to access that folder by specifying "/content/drive/My Drive/Project_R_Py/lib_py"
Hope this helps

I am trying to build a website that has a file manager on it. Is there any way to pull file paths and files from Google Drive?

I would also like to pull from Dropbox, Box, and iCloud Drive. If there is no way, I will try to work around it but I was just wondering. I would like to be able to see the whole drive (all files and folders accessible). Thanks.
Depending on what you exactly are looking to do, you can use Google Drive's API to create/open files on your Drive for a serious project. If you are just experimenting with an idea, you can host your site directly from Google Drive.
To display all the files including folders, use Files.list. If you want to specify which type of file you want to show, check Search Files.
To know more about working with folders and filepaths check Work with Folders

Downloading files from Drive using alt=media with correct filename

I'm having trouble allowing files (non-shared) to be downloaded from a Google Drive account. I've created a listing using the php drive sdk and would like to provide authorised links to download the files using a generated access token. I've got downloads working with links like this:
https://www.googleapis.com/drive/v3/files/[fileid]?alt=media&access_token=[access_token]
The problem is that whenever a file is downloaded, it is named [fileid].[extension], rather than the real file name that appears in Drive.
I've tried adding the download="[real filename]" into the a link to suggest the correct filename, but it's being ignored in all the browsers I've tried.
I've got an alternative working that gets the file piece by piece server side and echoes it out as a file via php, but I'd prefer for downloads to be straight from Drive to the user.

chrome.fileSystem on files/folders inside the app/extension

I am working on a Chrome App where I need the users to open files in a directory. For his own files, I can offer them a dialog through
chrome.fileSystem.chooseEntry
which works well. However that seems to limit me to the "Downloads" directory and Google Drive on my Chromebook. I would also like to ship some files with the application itself, so the files/folders would be located inside the app package. Is it possible to access these files through the fileSystem API?
I would not need the user to choose the files from a dialogue, it would be enough if I could get a handle to these files and offer to display them on the click of a button through my app.
Thanks in advance
You can read included files using chrome.runtime.getPackageDirectoryEntry(function(directoryEntry) {})

Uploaded file sometimes doesn't appear on the Google Drive web page

I've observed a strange behavior of Google Drive when I uploaded several files in a row to Google Drive by calling Google Drive APIs.
Everything seems working properly, I can get correct response back from API, such as file ID and URL. But when I looked into the folder where I uploaded files by web browser, files are sometimes missing.
This issue can be resolved by accessing the following URL which should not be necessary.
https://docs.google.com/file/d/<file ID>/edit
Could it be a Google Drive bug?
I've had the same problem. Usually the file would appear after some time. But sometimes not at all!
I've also noticed discrepancies between files shown in the web UI and files shown in the Google Drive directory on my PC. I would chalk this up to Drive's bugs.
Google drive still does this.
Files can take a long time to appear on the web gui. Similarly deleted files can remain on the web gui for a long time (and you get an error if you click on them).
I would really love a way to make drive more responsive.
İf you are uploading your files inside a folder then this might cause a problem. Make sure that parent folder exists for the file that you upload.