How to print documents and spreedsheets from google drive - printing

I can't seem to find information on how to print files through google app script.
I found an answer in this website but it doesn't work, I think it's because it's 3 years old and google script has had some changes.
google app script print button

You can't print directly from GAS (I've searched far and wide), as described in the post that you linked. However it is possible to create a downloadable document with the desired content and then pass that blob off to the client for downloading (depending on wether you're still working in GAS or a web app environment).
Personally, I felt that it was a headache to deal with how each browser deals with downloading blobs. Therefore I usually go one of these two routes: provide a public downloadable link from the drive of the owner of the script and then push it to the user to download, OR just email the document to the user and let their email client handle downloading the blob.
Alternatively, if this is an add-on, you can make it so that the document is downloaded directly to the users own drive and just inform them where the document will be located.

Related

Get one stable link for Multiple excel sheets with the same name from Google Drive into PowerBi

On daily basis I am getting an attachment in email. Basically that attachment is an excel spreadsheet. I am pushing that spreadsheet to google drive folder ./attachments using Microsoft Power Automate. The main purpose of pushing that spreadsheet into google drive is to load into PowerBi for Analytics purposes.
In PowerBi I am using the "Web" connector to import the file and it's working fine. The sample link is below.
https://docs.google.com/spreadsheets/u/2/d/1eBJR6wrcFrdjv4Lbf_Wq3MQOeUwBbgLw/export?format=xlsx
The above link exports the file into powerBi and hence I can load data into PowerBi.
The problem is, on daily basis I am getting new file in drive and the Unique Id of the file is not same. In the above example the unique Id 1eBJR6wrcFrdjv4Lbf_Wq3MQOeUwBbgLw will be different for the second file even though I am renaming the file with the same name using Microsoft Power Automate when pushing to Google Drive. eg: "PowerBi load file.xlsx". Is that possible that I can get a stable link for all the files with the same name?.
I have also shared the whole folder ./attachments and tried to get the link of the file but that doesn't work. eg:
https://drive.google.com/drive/folders/1h1VuPtXfWflgIQw7ecMTwweoLblADscq/PowerBi Analytics file.xlsx/export?format=xlsx
Any help, suggestions will be really appreciated.
Thanks everyone.
I believe your goals as follows.
You want to retrieve the file IDs from a filename.
You want to retrieve the file IDs from a shared folder.
Answer for question 1:
In order to retrieve the file IDs from a filename, I think that the method of "Files: list" of Drive API can be used.
The endpoint is as follows.
GET https://www.googleapis.com/drive/v3/files?q=name%3D%27{filename}%27
The search query is name='{filename}'.
In this case, the API key cannot be directly used because the file list tries to be retrieved from the while Google Drive including the file. In this case, the access token is required to be used.
By this, I thought that your goal 2 might be suitable.
Answer for question 2:
In order to retrieve the file IDs from a shared folder, I think that the method of "Files: list" of Drive API can be also used. In this case, at least, the file list is retrieved from the shared folder. By this, the API key can be used.
The endpoint is as follows.
GET https://www.googleapis.com/drive/v3/files?q=%271h1VuPtXfWflgIQw7ecMTwweoLblADscq%27%20in%20parents&key=[YOUR_API_KEY]
The search query is '1h1VuPtXfWflgIQw7ecMTwweoLblADscq' in parents.
In this case, the file list can be retrieved using the API key because the folder is publicly shared and the file list is directly retrieved from the publicly shared.
But, in order to use this, it is required to use the API key. Please be careful this.
Other pattern:
If you want to achieve your goal without the API key and the access token, I would like to propose to use the Web Apps created by Google Apps Script as a wrapper API. When this Web Apps is used, you can achieve above both goals without using the API key and the access token.
The official document of Web Apps is here.
The unofficial document of Web Apps including several sample situations is here.
References:
Files: list
Search for files and folders

Uploading pdf files stored in iphone to server in ios

I am making an iphone application which is pretty much like forum. People can ask question and upload a pdf/doc file along with the question. Is there a way to access the pdf/doc file in iphone when user clicks upload button and send the file to server?
I have implemented the feature for image for which I used UIImagePicker to pick the image and send it to the server with http request. But I am completely lost and have no idea how to handle pdf/doc files in same manner.
Any help/suggestion really appreciated. Thanks in advance.
If you want to upload PDF and Doc files, then you can integrate Dropbox and Google Drive in your app and then select the files ,as Apple does not have centralised storage. If you notice Apple also chooses the documents from Google Drive while composing a mail.
So implementing and integrating google drive and Dropbox would be a good option.
Here is the link for Dropbox https://www.dropbox.com/developers-v1/core/sdks/ios
Here is the link for Google Drive https://developers.google.com/drive/ios/quickstart
Implementing Google drive is a bit hard but dropbox is quite simple.
Wish it saves your time. All the best!
I think you are looking for a combination of two things (both have been discussed here before and I include the links below).
(1) store a PDF. There are many options but the best way is to allow coredata to save outside the persistent store. Then store the reference to the file in core date. See: Insert a PDF file into Core Data?
(2) send the file to the server. There are many options for this as well. The fastest is probably to use a wrapper library such as ASIHTTPRequest. See: File Upload to HTTP server in iphone programming

Use Google Drive as an external editor

I have a website that stores, parses and display .docx files. I want to give users a way to edit those files.
I don't want to embed a third-party widget in my website and I thought that I could use Google Drive API. My idea is that I can give user a button “Edit in Google Drive” which back to my server somehow.
The problem is that I haven't found neither API function that allows to do that nor examples of such approach.
Am I on the right way? Can my idea work? If yes, then how can I do it?
Look at the drive api. There is one to upload a new file and optionally convert it to native google format.
To upload it, read about using oauth2 to authorize storing it on the user's drive. User must have Drive of course.
After the user finishes editing, they press a button or something on your site so you use the drive api to either read the gdoc and convert yourself to docx or use the drive api to download as docx.
Both uses of drive api are explained in the docs.

Google Drive as a video hosting/streaming platform?

I'm developing an iOS app that generate video files and have a social gallery for users to display their clips. After a lot of research I found that Google Drive would be perfect to fit my needs so I did some testing and sucessfully made the app upload the file to GDrive and everything.
Now I need to stream the uploaded file in a MPMoviePlayerViewController, for that I would need some kind of direct link, I'm right? After my initial tests I used the variable WebContentLink as a source URL and it worked flawlessly, I was really happy with the result, however now it doesn't work anymore, I don't know what happened and I think the method that I used is not realiable? I tried all the other possible links and none of them seems to work.
Can someone give a guidance about if this is really supported by Google Drive and how it's the best way to archive that in a reliable way?
Thank you very much !
I too encounter the same error when I try to download 28 times (testing) the same 24mb file.
However I realise if I am to download using the content owner ID, it does allow downloading after the 28th time
https://docs.google.com/a/onwardsct.com/uc?id=0ByvXJAlpPqQPYWNqY0V3MGs0Ujg&export=download
Sorry, you can't view or download this file at this time.
Too many users have viewed or downloaded this file recently. Please try accessing the file again later. If the file you are trying to access is particularly large or is shared with many people, it may take up to 24 hours to be able to view or download the file. If you still can't access a file after 24 hours, contact your domain administrator.
The experience for streaming files natively is not ideal right now, sorry. It is something Google are working on.
You are doing this correctly though. The webContentLink should use the user's quota, and that should be enough for most cases. If you can give some specific numbers, we can look at it.
The embed link is the best way to show it on a mobile device, but as you say won't work everywhere.
yes, google drive can be used for hosting and stream videos as you like. It can also be used as demo server for web projects. Here is how to host a website on Google drive.

Selectively uploading files to a website

My office uses a piece of software that generates XML based reports. These reports also reference images files which are created during the generation of a report.
I'm trying to develop an ASP.NET MVC web app that will allow users to share and collaborate on these reports. The site will read the XML data into a database, as well as store the images files to be viewed on the site.
However, the problem I'm having now is the reporting software generates many more images then are actually needed by my site. After reading through the XML report data my site will typically find that it really only needs a few images uploaded out of all images that were exported by the software.
I don't want to waste bandwidth or time by having the user upload every single image to the site, as most would end up just being deleted after the site reads through the XML file.
Is there any other way to allow a web-app to selectively upload files from a users computer? Ultimately I would like for the site to be able to read in the XML report file, determine what image files it needs, and then proceed to upload only those images.
Could this be accomplished through java script in the page? What about a silver light?
I know I could develop a stand alone executable that would handle parsing the XML and uploading the images. But I'm trying to avoid requiring the user to install anything to use this site.
unfortunately for security reason it's not very easy to have a web app access the local drive and copy files to the server. However, here are some suggestions:
Create an activeX that has full access to the users computer. (IE Only, has to be installed) basic activex, old example to upload files.
Create an applet, similar to ActiveX (cross browser). Example
Completely different idea, but maybe a bit simpler, you could have the user upload the xml, the server would determine which images it needs and display it to the user. The user could then do a multiple file upload of just the files you listed.
Best of luck.

Resources