Uploaded file sometimes doesn't appear on the Google Drive web page - google-drive-api

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.

Related

How to get a direct link from Google Drive?

I know it is possible to get a link that will initiate a download of a file from Google Drive. But this is not exactly what I am looking for. I want to be able to have the link of a file with its extension.
For example, it is possible to do this with Dropbox. I am able to get a direct link if I change "www.dropbox.com" to "dl.dropboxusercontent.com". So if I have a video file, it will play on the browser's player instead of opening the page to download it.
With Google Drive I don't know how to do this. If I generate a direct link, it will then create a link that automatically starts a download. A direct link for a .txt file will not be rendered on the browser. It will be downloaded instead.
So, it is possible to have a direct link to a file in Google Drive that is not the direct link that starts downloading automatically, but instead with the directory/file.ext?
There are several things you need to understand about how the Google drive api works.
When you do a file.get with the Google Drive api it returns a file resource this is the response for the file itself. The information about it that google is willing to share with us. There are two fields here you may find interesting
The first thing you should know is that a file has one or the other of these links not both. If the file is a binary type for example an image you will be given a webContentLink which can be used to download the file, If its say a google sheet then you will be given a webViewLink which can be used to view the file in Google Drive web application.
Which link you get depends entirely upon the type of file it is. No matter which link you get you will still need to have permission to access this file. So whoever clicks the link must have at the very least read permission to the file.
On the Google drive web application we can create links which can be shared with anyone and allow anyone to "access" there is no way to create these links VIA the api.
What you wish to do is out of scope for the Google drive api, probably due to security reasons. Also the simple fact that google drive api is not a file service api it a file storage system. THere is a difference.

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

Get file list from google drive public folder shared by link via API

I'm trying to create script to download all files from another user shared folder in google drive using rest api. If i'm right, there are two variants:
Using drive.children.list, with folder ID
Using drive.files.list, with search query like 'FOLDER_ID in parents'
But both of this variants returning only files which were once opened by my google account in browser. If I open file in browser - this file will appear in results of API calls.
Folder is shared for anyone, who has link.
Where is the problem, how I can list all files in folder?
Since you did not give us any info about the SCOPE, I am wild-guessing that it may be your problem. You probably have FILE scope, instead of DRIVE.
Also, I would recommend to test these things with 'TryIt!' here. You can quickly modify both scopes and queries there.
Good Luck
This is a bug/quirk in the Drive API, though there is an easy workaround. If you call files.update with 'addParents=root' it'll add the shared folder under 'My Drive'. This has the effect of making the files part of your corpus and they'll appear in results.

How to edit HTML in Google Drive?

I have hosted a HTML file created on my PC (along with a stylesheet) on Google Drive using the script described here.
I have given out the link and it seems to be working fine (no reported issues from those I've sent it to).
I have just discovered a minor omission from the file, I need to add another sentence. This should be ridiculously easy on a PC, I could just open it on notepad!
I can't find a way to edit it on Google Drive, the only connected apps are the viewer and Docs.
The viewer, as the name suggests, will only let me view the HTML, and the docs app won't let me save it back to the original file.
Obviously I could download it then upload again, but from experience it will probably give me a different URL.
Is there any way for me to do this while keeping the link the same, as I have already given the address out?
Currently you can't. You can only preview html files, that is preview the code or preview the rendered content, but you cannot natively edit the code. You have two options:
use a third party extension, such as Neutron Drive or Drive Notepad.
install the Google Drive Desktop App, edit your files locally and save. Changes will be uploaded automatically.
I have just used HTML Editey chrome app
You can do this through file revisions. Hopefully, Google adds another way, but using the revision feature works for me. To revise your file, click the check mark in the Google Drive file list, click more, and then click "Manage revisions...". In the box that pops up, click upload new revision and then you're set.
You may also be able to edit html files stored in google drive through other plugins, but I do not use any at this time to know of them.
Update!
go to drive right click your html file
choose "open with" then "connect more apps"
when app library pop up search for "notepad" then choose "drivenotepad"
after it connect to drive, select it, you will get code editor.