Using the Google Drive API I can get a file's webViewLink to link to the file-preview in Drive, and the user can then select 'Open with Google Sheets' in the top bar to open the file up in Sheets.
Is there a way to skip that intermediary step, and link directly to that file in Google Sheets?
File.resource also contains a link called webViewLink
webViewLink string A link for opening the file in a relevant Google editor or viewer in a browser.
This will not work on all file types but it should work on sheets.
What are you seeing in webViewLink?
When I try, I get
"webViewLink": https://docs.google.com/spreadsheets/d/1egZQnArX7TOHlQWSHiba3TTNt9Y7JoqgDAIJMdM0MQ/edit?usp=drivesdk"
which directly opens the sheet.
So a couple of things:-
Are you sure that the file in question is a native Google spreadsheet, or is it, for example, an uploaded Excel
If your webViewLink is different, you could construct the URL yourself by setting your own file's ID after the /d/
Related
I noticed this behavior on Google Drive.
When a link is created for a file on Google Drive, the link is valid until the file is deleted.
Moving the file to another folder(s) does not affect the behavior of url.
I will like to understand how they achieved this at scale.
This is an expected behavior when moving files to another folder within your google drive. This is because a google file URL is usually composed of the following:
product domain
product
document Id
Therefore, moving the file to another folder within the google drive will not affect the file URL because file path is not included in the URL format.
References:
Google Sheets API Overview
Docs API
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.
I am uploading Word documents to Google Drive using the Google SDK. I can view these files once uploaded through the Google Drive interface, but to edit these documents I need to selected "Open with Google Docs". When I do this, Google makes another version of the file and saves it to my Google Drive.
I want to automatically create a URL for users to click on once their file has been uploaded, so I presume I somehow need to convert the uploaded file (Word Document) to a Google Docs file so a user can then edit it and save it. Is this possible?
You need to send the optional query parameter of convert
convert (boolean) Whether to convert this file to the corresponding
Google Docs format. (Default: false)
Documentation for Google Drive Insert
I can develop downloading a spreadsheet file as html function when I use documents list api, but I can't download spreadsheet as html using drive api.
I've found this problem after migrating from docs list api to drive api.
Is there any way to downloading a spreadsheet as html using drive api?
Please advise,
Thanks.
With Old style spreadsheet (max 400,000 cells) this works:
Download a Google Docs Spreadsheet as HTML
With new style spreadsheet, I have not tested, but I assume you can use the above method to download it as a zip. So if you open your spreadsheet, select download as html, it will give you the link to the zip. Use this link as described in "Download a Google Docs Spreadsheet as HTML". So, I have not tested this, but it looks like everything is the same, so it might work.
Is it possible to create a new Google Docs document, and then open it in the Google Docs editor? We have documents in our site that would be great to upload to Google Docs for editing but I'm having trouble figuring out if that's possible between the deprecated docs list API, and the new Google Drive API. Thanks.
Yes.
When you upload a file you will get back an item resource which contains a field AlternateLink. This is the edit URL.
To try it, go to https://developers.google.com/drive/v2/reference/files/get#try-it, click Oauth to On, then paste one of your file IDs into the fileId field. When you get back the item resource, just click the AlternateLink