Wednesday, February 24, 2021
Home Development How to Make your Documents Read-only in Google Drive

How to Make your Documents Read-only in Google Drive

The documents in your Google Drive are private of course and just the proprietor has beginning authorizations to see, alter or erase their records. On the off chance that you decide to impart a document to others, you can choose whether others have perused possibly admittance to your records or in the event that they are permitted to alter and remark on your records.

You can generally eliminate outside associates from your reports to keep them from altering your records however how would you forestall yourself (the proprietor) from unintentionally altering your own documents in Google Drive?

How to Make your Documents Read-only in Google Drive

Google Drive currently has another Locking API to assist engineers with including content limitations archives, bookkeeping pages, introductions, PDF and some other document in Google Drive.

At the point when you lock a document, nobody (counting the proprietor) can make alters to the record, the record title can’t be changed and furthermore lose the choice of remarking inside documents.

Google Drive doesn’t have a basic catch (yet) for locking documents so here’s a little Google Script that can help you make any record in your Google Drive read-as it were.

  1. Open Google Drive and right-click any record that you wish to make a read-just document. Snap the Share Link menu and duplicate the document connect to the clipboard.
https://docs.google.com/spreadsheets/d/12345_abcdef-123/edit?usp=sharing
  1. Type script.new in the program to open another Google Apps Script undertaking and duplicate glue this piece in the code proofreader.
/**
 *  Make Google Drive files Read only
 *  Author: amit@labnol.org
 *  Web: https://digitalinspiration.com/
 *  MIT License
 **/
const makeFileReadyOnly = () => {
  const fileUrl = '<<FILE URL>>';
  const [fileId] = fileUrl.split('/').filter((e) => /[_-\w]{25,}/.test(e));
  UrlFetchApp.fetch(`https://www.googleapis.com/drive/v3/files/${fileId}`, {
    method: 'PATCH',
    contentType: 'application/json',
    headers: {
      Authorization: `Bearer ${ScriptApp.getOAuthToken()}`,
    },
    payload: JSON.stringify({
      contentRestrictions: [
        {
          readOnly: true,
          reason: 'Prevent accidental editing',
        },
      ],
    }),
  });
  // For requesting correct scope, do not delete
  // var file = DriveApp.getFileById().setName()
};
  1. Supplant the FILE URL in line #2 with the URL of the Drive record that you duplicated in the past advance.
  2. Go to the Run menu, pick Run work > make File Ready Only. Acknowledge the authorizations and your document will confined from altering by anybody including yourself.

On the off chance that you might want to eliminate the document bolt and permit altering, open Google Drive, right snap a similar record and pick “Open document” from the menu to reestablish the altering conduct.

How to Make your Documents Read-only in Google Drive

Kindly note that when you freeze an archive with the Google Drive Lock API, even Google Scripts and Google Workspace additional items are obstructed from altering the document.

namanmahajanhttp://artistogram.in
I am a Multimedia artist, I am born and based on Dewas (M.P), I am working as a freelancer with various brands and different country. My expertise are Graphics designing, motion graphics, 2d/3d animation, advertising videos, cartoons designing, all types of packaging and branding designing, digital marketing, SEO, design website and app Developments etc...

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular