Google Drive API QuickStart NODE.JS sample doesn't work - google-api

Using the exact example code given in the Google Drive APIs | Node.js Quickstart, the file information that is retrieved is not an accurate representation of the contents of my Google Drive. That is, even though there are 100+ filenames displayed, only one file (a folder) is actually on the 'My Drive' for my account!
Also I have then tried to 'filter' the files selected by using the query string (eg. "q: mimeType='image/jpeg'", and others), but it has no affect; the exact same results are returned.
Here is a truncated sample of the output. The 'Temporary' file is the folder which does exist in my account's "Google Drive 'My Drive'" but the others do not.
Files:
Temporary (17xAXYQzw0zYHpjeUP03sdx7qPd1Cnvv0)
Core Odd Years (0BxSZz46t09z1d0t1VWFkTkVkeWs)
Core Even Years (0BxSZz46t09z1ZTVVcm1lWEZvXzA)
Lesson Plans (1AhnLWyjBqtgTa-ofelROlZsnmzX1HiCl)
Hobbies (0BxSZz46t09z1ZkVQbTRiMTB1YTQ)
Hobbies-Steps-Overview.pdf (1E0E15rNOMCHV7OrjMCihjPK2yNLVpIdj)
Heritage (0BxSZz46t09z1cEpiWlYxWm1rNjA)
...
I expect that this is a well inspected example, so I'm unsure what could be the issue. Any help is appreciated.

If you are still looking for the solution, how about this answer? I think that 2 issues might be included in your situation.
About files which are not existing in your Google Drive.
The files might be the shared files.
In your question, you say that q cannot be used.
This might be due to the version of googleapis.
In order to confirm above issues, can you try the following 3 points?
For q, please try to use q: "'me' in owners".
This means that the files without sharing are displayed.
This is the same to sharedWithMe = false. Because sharedWithMe = false cannot be used, q: "'me' in owners" is used for this situation.
For q, please try to use q: "sharedWithMe".
This means that only the shared files are displayed.
Or please confirm "Shared with me" in your Google Drive using your browser.
If q: "'me' in owners" and q: "sharedWithMe" cannot be used for your environment, please confirm the version of googleapis for node.js.
If you are using no latest version, please update to the latest one. The current version is v28.0.1.
I confirmed that the sample script of quickstart can be used for v27.0.0 - v28.0.1.
Reference :
Search for Files
If my answer is not useful for you, I'm sorry.

Related

Can a script be too new for a google sheet?

I work on a google sheet that has several departments looking at and/or adding data to all day long every day. I have been working on making scripts to make my departments life a lot easier.I created an exact duplicate of the sheet so I could make sure it works before executing new scripts.
I have one that sets up an order, sends an email and puts it on the calendar all in one click. It works great.
In the email we need to send a link to a job folder. So we have a script to find that folder and get the link to it.
var folder = DriveApp.getFoldersByName("12345 - Help me")
var in = folder.next()
var link = in.getUrl()
In my testing grounds this works exactly how it should. When I put it into the actual sheet that we work in I get an error
"Error Exception: We're sorry, a server error occurred. Please wait a bit and try again."
I have been trying to figure it out for 4 days so far and am getting nowhere.
I had the "owner" of the sheet transfer it into my ownership incase that was the problem.
I moved it to a shared drive.
Made a copy of the whole spreadsheet to test it; it worked in the copy just fine.
To change over to a new spreadsheet will be a lot of work that would have to take place after work hours when no one should be using it. I am hoping there is a way to refresh the spreadsheet in such a way that we need to reapprove scripts (or something). The spreadsheet in question was created in 2018. I am wondering if its just to old for the script; not that that makes any sense but, I cant think of anything else.
Thoughts?
From the question
The spreadsheet in question was created in 2018. I am wondering if its just to old for the script; not that that makes any sense but, I cant think of anything else.
Nowadays Google Apps Scripts supports two runtimes, the old (Rhino) and the new (V8). There are posts sharing that changing the runtime to the one or the other fixed an issue. Considering this, the first thing to check if what runtime are being used on each Google Apps Script that are being used as "testing grounds" and in production as sometimes one of the source of "confusions" is to use different runtime.
Another thing to try is to create a standard Google Cloud Platform Project (GCP) to replace the default GCP project. On this project enable the Google Drive API.
Resources
https://developers.google.com/apps-script/guides/v8-runtime
https://developers.google.com/apps-script/guides/support/troubleshooting

How to get the id of files inside a shared google drive folder using only the shareable link?

I am looking for a way to get around using the API key to download files from a shared folder in google drive. The only thing I need is a method to automate the extraction of IDs from each file inside the shared folder.
Any solution would be helpful.
Stack Overflow is a forum where developers can help other developers with their doubts. It is not intended to solve ambiguous issues, where it is shown that previous research or effort in doing the task hasn't been made.
Here can be seen how to ask a good question.

Malicious code hidden in image

I've come across a dodgy file upload on our server. It is an image and the MIME TYPE checks out, though on the server it was also uploaded with the extension .asp and .cer.
On the surface its a photo some weird chinese symbols and the letters asp, though I am sure it is hiding malicious code. I did a google search by image and it came out in a few possibly unsecure directories in some other sites.
This is out of my league to even verify. Out of interest I opened the file in notepad and it has the clear string "Google" which only makes me believe more that it is malicious.
All I need to know is
1- is it malicious?
2-did it run and what did it do?
3- how do i protect against it?
I cant give the link to the actual file on my server since Its been removed, but I can zip and mail it to anyone who wants to take a look.
If anyone has some advise on where to start I would appreciate it.
Heres a link to the same image, which came up on my google search though this one most likely has different code injected
http://www.bakjuweel.be/ShowImage.aspx?img=/upload/fotogalerijen/13/3.asp;.jpg&w=135&h=111
UPDATE
After alot more research I have found that it had a modified header to inject code. I run it through virustotal.com and my suspicious were confirmed. https://www.virustotal.com/en/file/3eac6e45d5923632089b538ca86d576c9994bd25be7940165ec997484d7c6715/analysis/
What it does or whether it executed is still unknown
OK, the file was malicious it contained encoded php, all of which im not sure of there were far too many encoded layers. It created a backdoor that fetched and executed remote code. This file was not detected by any of our antivirus software, what gave it away way was <% eval(. was the only part not encoded.A hacker took advantage of a vunerability in an old version of FCKeditor to add and execute it. I am still looking for a way to prevent it in the future.

Local file link to shared dropbox files

Since this is my first time posting a question on stackexchange, please excuse me if I've not included anything. Suggestions for a better post are very welcome!
Background
I'm looking for a way to create a file:// link in e-mails with a specific purpose. In my company we're all using Macbooks with Outlook as our e-mail-client. As soon as a specific document is updated, I would like to be able to e-mail a colleague saying: "here is the to the file". My personal link would be: file:///Users/<MyUserName>/Dropbox/Filepath.ext. However, this does not evaluate correctly on my colleagues computer. I have made it to work with a manual username change, but I'm hoping that there is a way to automatically fill in the username of that person.
My Question:
How can I make the link in such a way that it will always refer to that user's specific user folder?
Resources explored
I've tried working with file://~/ but that always gives a 'can't find the document' error. I've tried googling it but Dropbox and other services only point towards URL-links or to their website. Stackexchange hasn't provided me with an answer so far (Internal links / ":file//" links is without answer). Searching for 'computer independent file links' haven't given me any solace either.
Any help would be greatly appreciated!
not sure if this is what you want. You can check the dorpbox API and read a bit about it. But an easier way might be IFTTT, a free tool which launch triggers. So basically you need to create a folder in dropbox for each user and then use this tool to make triggers for each user. You can send an email and include the new dropbox link and as well you can program the IFTTT to send a file://Users//Dropbox/USER_DROPBOX_FOLDER/{{FILENAME}} whenever a file is placed in his folder.

windows hard link - protect against writes

I have a bunch of files that I download at some point and then customize. I want to keep the originals, but also allow modifications, and I want to do this using hard links.
I figure I first download the batch of files into some sort of repository, then create hard links into my work location. I want to let the user delete his files (e.g. delete the hard link), which doesn't pose problems.
However I also want to let him write to them, in which case I want my original file to be left untouched in the repository, so I can revert later. How can I do this transparently, without actually locking the file and forcing him to delete it and recreate it?
Any ideas greatly appreciated, thanks.
Cosmin
In windows you have no such option as NTFS/FAT doesn't support snapshots. Hard links are just links anyway, both point to a single file and if link A is changed link B is changed also.
You can partially achive the same result with Windows File History however I don't know any way to set it up exaclty as you described.

Resources