So I am using the Google Drive api to upload files to Google drive and when the upload is completed, I am opening the uploaded file by accessing the webViewLink
property in the metadata that is returned. But for some file types it is returning edit link instead of view link, for example,
Edit link: "https://docs.google.com/document/d/1-ZvUwZj1aJRmVfUAlUnzy6PLbzRBZh/edit?usp=drivesdk&ouid=103011368539855&rtpof=true&sd=true" (for POT,DOTX,DOTM,DOT,DOCX,,DOCM,DOC,PPS,PPTX,PPT,XLS,XLT,XLSX files)
View link: "https://drive.google.com/file/d/16U6Zg_8t0A9P2HW_vGoS/view?usp=drivesdk" (for all other MS office files)
After some investigation on my own, I found out that this is because of the mime type associated with those particular file types. If I forcibly set the mime type to one which gave me the view link, then I get the view link for those file types which were giving me edit links.
So my question is, why does it return edit link based on this mime type? And what can we do to either get the edit link or view link (is there a way to specify this)? And if we forcibly set the mime type to some other value that works for me, what can go wrong?
why does it return edit link based on this mime type?
webViewLink
(you can also check it directly in the drive, using Get Link
). See Open Office files in DriveAdditional Reference: Google has made the editing office files easier
what can we do to either get the edit link or view link (is there a way to specify this)?
if we forcibly set the mime type to some other value that works for me, what can go wrong?
mimetype
is supported, you can open it with the suggested options in your drive using open with
. See supported file types