Google Drive – How to Anonymously Upload Files

google-drive

I work remotely on camera systems and sometimes I have to backup some footage to cloud storage. Up to this point I've been signing into my Google Drive and uploading the files there for me to download at the home location.

However, the uploads usually take a while and I'd rather not leave the remote computer logged in and unattended while they are uploading. Is there any way I can upload to my drive without signing in (perhaps doing a one-time code or something of the sort)?

Best Answer

This might work.

Allow Others to Upload Files to Your Google Drive with This Script

The script itself is here:

function doGet(e) {
  return HtmlService.createHtmlOutputFromFile('form.html');
}

function uploadFiles(form) {

  try {

    var dropbox = "Student Files";
    var folder, folders = DriveApp.getFoldersByName(dropbox);

    if (folders.hasNext()) {
      folder = folders.next();
    } else {
      folder = DriveApp.createFolder(dropbox);
    }

    var blob = form.myFile;    
    var file = folder.createFile(blob);    
    file.setDescription("Uploaded by " + form.myName);

    return "File uploaded successfully " + file.getUrl();

  } catch (error) {

    return error.toString();
  }

}

Once added to drive people can submit using a form:

<form id="myForm">

    <label>Your Name</label>
    <input type="text" name="myName">

    <label>Pick a file</label>
    <input type="file" name="myFile">

    <input type="submit" value="Upload File" 
               onclick="google.script.run
                        .uploadFiles(this.parentNode);
                        return false;">
</form>