Download image from url with google spreadsheet script - google-apps-script

I'm using google spreadsheet app to parse information from a webstore. So far I've managed to get all the needed information except the images of products. I have the link to the image stored in a variable like this:
var test = 'http://.....image.jpg'
what I need to do is to download the image to my PC into any folder without any confirmation, since all of this will be done in a loop to download all the images from a webpage.

Related

How to fetch the URL of an uploaded IMAGE or VIDEO from a GOOGLE FORM using GOOGLE APP SCRIPT?

I'm trying to create a google app script function where I want to fetch the URL of the image/video uploaded in the google form so that I can use it to display in my google web app. I'm not able to find any solution.
In the image below, the page source shows the URL of the image that was uploaded in the form. This URL is what I want from the app script.
When a file is uploaded via a Google Form, the file is placed in a folder within the form owner's Google Drive.
If you are the form owner, a new folder will be created within your drive and you will be able to access them using the Google Drive API.
Check out the documentation here: https://developers.google.com/drive/api/v3/search-files
If you know the name of the form, you can search the Folder within your drive and then use the API list the files within that folder using files.list .
You can find the fields within Files here: https://developers.google.com/drive/api/v3/reference/files and can use these fields to any specific URLs.

Get link to Google Drive presentation file

I am creating an webpage that allows my users to select from a list of presentations (.ppt and .pptx) I have stored in a Google Drive folder. I can query the folder and list the files easily enough and using the alternateLink property I can get a link that opens the file for editing in the Google Slides app, like so:
https://docs.google.com/file/d/<ID property of File goes here>/edit?usp=drivesdk
I want to get the link that is created when you view the presentation, like this:
https://docs.google.com/presentation/d/<some ID goes here>/edit#slide=id.p
I can create this link manually by concatenating strings, but I can't figure out where the ID value comes from. Does anyone know?
UPDATE: So, I posted this question and went into the kitchen to eat. While I was eating it occurred to me that the difference isn't in the IDs of the files, it's in the file formats. When you open a PPT file in Google Slides, (I think) Drive converts the file to the Google Slides (.gslides) format before showing it. It uses the ID of the newly created file in the presentation link (second link above). If I put a .ppt file ID in the second link I get a "this file doesn't exist" error from Drive. If I put the ID of a .gslides file in the second link it opens in the Google Slides app as expected.
On your update, Nailed it. There is not a method to get presentation URL for a ppt or pptx document. If it was already a Google Slides document, then you would have access to the presentation URL via the metadata for that file.

Upload files through Google Chrome

So I'm about to attempt to upload several files through a Google Chrome Extension.
Instead of pressing the Upload button on the webpage and load each file one by one I want to automate it.
How should I go about this? Is it as simple as detecting the script inside the DOM responsible with uploading, changing the file_to_upload string from the scipt with a filename on my computer and injecting the new script and execute it ?

Google Realtime API with Google Docs

I would like to build an application on a webpage, that does as google docs:
I want to build an app that allow people to work on a document in collaboration
I start with this: https://developers.google.com/drive/realtime/realtime-quickstart
But the problem is that it creates a file with the mimetype is "application/vnd.google-apps.drive-sdk".
I would like to work with google docs format, so people can open them with their google drive and edit their later.
The file created is not the proper format, and find it me impossible to open it.
( I try to edit the mimetype with "application/vnd.google-apps.document", however it creates the file in the google drive but it can't find the file when it try to load it).
How to create a google doc in realtime ? (If you can post the code here, it would help me a lot)
Then, it want to add the toolbar for editing(bold, italic,...).
After that, it would like to add the google picker to select the file to load.

Creating a Google Apps Script which Automatically Executes on Upload

I have an interesting fairly simple problem I am trying to solve but I am at a loss on the proper code to get this to working correctly.
Basically, I have an very old local application running which allow me to print a receipt of a transaction. I have the ability to enable this receipt to be printed to a specific file within a specific directory on my computer or I can set it up to print out automatically to a printer on my computer. Currently I print the data out to a file, then copy the contents of that file and paste it into a word document template and then manually go through and format the data so it looks clean (I should note that the data prints out in fixed field format requiring a specific font and size so its pasts correctly. After all this is done I then email the word or pdf document out.
Essentially what I am trying to do here is automate this method and I thought this should be possible using a Google Apps Script.
My thought here was that it should be possible to:
save all the original files from my application to a specific
directory on my computer
sync that folder with google drive
have a google apps script automatically execute upon upload
have the google apps script automatically use a specific document
template I create with a header/footer and then paste all the
contents from the new file which was uploaded
have the google apps script pattern match certain elements within the contents of
the document and properly format it.
save the document to a specific location with a specific file naming convention
automatically email the document as a doc or pdf based upon a
specific regex matched field within the source document.
Could anyone provide a specific code example which demonstrates how Google apps scripts can be utilized to monitor the contents of a specific Google drive folder to trigger an event immediately after a new file is uploaded?
Thanks in advance!