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) {})
Related
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 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
I am trying to build a Google Chrome Extension which does the following -
1) Gets activated when someone visits my site say http://example.com
2) When someone downloads a file from my site , http://example.com, it starts monitoring that file for changes.
3) If the user edits and saves that file, it uploads the modified file back to the system.
My site is a niche document management system for a particular industry. Users dont want to downloads files, edit and then re-upload again. They want the files to be uploaded as soon as they save on their side. Its mostly for .docx, .xlsx files.
I tried to look at the Google chrome apis, but couldnt locate the appropriate ones. Any help would be useful.
Thanks!
As per your description, I believe chrome.downloads is what you want.
Use the chrome.downloads API to programmatically initiate, monitor, manipulate, and search for downloads.
To monitor, you could listen to chrome.downloads.onCreated and chrome.downloads.onChanged
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...
I am building a chrome app for Digital Signage where I need the user to select some files from a particular folder (preferably in the app's directory) i.e audio, videos, photos which should be created by the app on install.
The sample code provided by Google requires that the user navigates to a folder like this
chrome.fileSystem.chooseEntry({type: 'openDirectory'}, function(theEntry) {
if (!theEntry) {
output.textContent = 'No Directory selected.';
return;
}
// use local storage to retain access to this file
chrome.storage.local.set({'chosenFile': chrome.fileSystem.retainEntry(theEntry)});
loadDirEntry(theEntry);
});
However, my app simply needs the name of files in that (say Video) known directory for the user to build a playlist, rather than actually selecting a video file.
Is this supported in chrome.fileSystem API? Any pointers to how I cold get this done?
It sounds like you should be using either the app's sandboxed file systems, or the app's install folder itself.
The sandboxed file systems allow the app to store whatever data it wants, in whatever structure it wants. There are two to choose from: persistent or temporary. Temporary may be cleared at any point in time. To use these check out this article. Some of its code may be out of date with the spec. Note also apps need to request the unlimitedStorage to use these.
The install folder itself can be used in a read only way. To do this you use chrome.runtime.getPackageDirectoryEntry.