[V4/FREE] Google Drive Extension | Secure | Database-like

share this aia file for test it.

1 Like


here single get response event for upload or get download link so its deficult to show image in kodular list format.
so you need to add function like Get direct link output type.

You are right :slight_smile: Sorry for the late reply. I am busy nowadays, but I will fix it as soon as possible :heart::+1::magic_wand:

:new_button: Updates 2025-08-31T18:00:00Z

1 Like

I found that your extension is really helpful. But I’m just curious, is the output file uploaded always txt files? Or I need to do something else to convert it as the original file extension?

Thanks for your comment.
No, you can upload any type of file.

Share your valuable feedback here.

[quote=“Glich, post:1, topic:295659”]
ADICIONE SUA PRÓPRIA CHAVE DE API SECRETA
which secret key we need to paste in script? reply someone

Hey, welcome to Kodular community

About the API key, he has explained it well, you need to follow this process below

I can read the list of files, but creating a file doesn’t work. Is it possible to create the file after taking a picture?

It would really help if you provided a screenshot your relevant blocks, so we can see what you are trying to do, and where the problem may be.

To get an image of your blocks, right click in the Blocks Editor and select “Download Blocks as Image”. You might want to use an image editor to crop etc. if required. Then post it here in the community.

Taifun

1 Like

Thanks for the reply. I managed to resolve the file upload issue; I had to remove the file:///. However, the file will always be sent as a .txt file.

Nobody is able to know what you are doing
Post a screenshot of your relevant blocks!
See also How to ask a question?

Taifun

I’m uploading an image to Drive after taking a photo. But the file is created as text in Drive. How can I save the file as a JPG?

Thanks @Echodroid for you valuable Message.

Use file:// instead of file:///

I managed to send it by removing file://, it worked fine, but to get the file to arrive as an image in Drive, I had to modify the createFile function in AppScript:

function createFile(data) {
  try {

    const folder = DriveApp.getFolderById(data.folderId);
    let file;

    if (data.content) {
      const bytes = Utilities.base64Decode(data.content);
      const blob = Utilities.newBlob(bytes, data.mimeType, data.name);
      file = folder.createFile(blob);
    } else {
      file = folder.createFile(data.name, data.content, "text/plain");
    }

    return output({
      success: true,
      fileId: file.getId(),
      url: file.getUrl()
    });

  } catch (e) {
    return output({ success: false, error: e.toString() });
  }
}
1 Like

Your are Absolutely right :white_check_mark:
I fixed this. here is the correct script for all kind of minetypes.

Correct Script
const API_KEY = "your-secret-key";

function doPost(e) {
  try {
    const data = JSON.parse(e.postData.contents);
    if (data.apiKey !== API_KEY) return output({ success: false, error: "Invalid API Key" });

    switch (data.action) {
      case "create": return createFile(data);
      case "edit": return editFile(data);
      case "delete": return deleteFile(data);
      case "rename": return renameFile(data);
      case "get": return getFile(data);
      case "download": return downloadFile(data);
      case "getlink": return getDirectLink(data);         
      case "list": return getFiles(data);                 
      default: return output({ success: false, error: "Unknown action" });
    }
  } catch (e) {
    return output({ success: false, error: e.toString() });
  }
}

function output(obj) {
  return ContentService.createTextOutput(JSON.stringify(obj)).setMimeType(ContentService.MimeType.JSON);
}

function createFile(data) {
  try {
    const bytes = Utilities.base64Decode(data.content); // decode base64
    const blob = Utilities.newBlob(bytes, data.mimeType, data.name); // create binary file

    const file = DriveApp
      .getFolderById(data.folderId)
      .createFile(blob);

    return output({ success: true, fileId: file.getId() });
  } catch (e) {
    return output({ success: false, error: e.toString() });
  }
}

function editFile(data) {
  DriveApp.getFileById(data.fileId).setContent(data.content);
  return output({ success: true });
}

function deleteFile(data) {
  DriveApp.getFileById(data.fileId).setTrashed(true);
  return output({ success: true });
}

function renameFile(data) {
  DriveApp.getFileById(data.fileId).setName(data.newName);
  return output({ success: true });
}

function getFile(data) {
  const content = DriveApp.getFileById(data.fileId).getBlob().getDataAsString();
  return output({ success: true, content });
}

function downloadFile(data) {
  try {
    const file = DriveApp.getFileById(data.fileId);
    const blob = file.getBlob();
    const base64 = Utilities.base64Encode(blob.getBytes());
    return output({
      success: true,
      fileName: file.getName(),
      mimeType: blob.getContentType(),
      base64: base64
    });
  } catch (e) {
    return output({ success: false, error: e.toString() });
  }
}

function getDirectLink(data) {
  try {
    const id = data.fileId;
    const url = "https://drive.google.com/uc?export=download&id=" + id;
    return output({ success: true, url });
  } catch (e) {
    return output({ success: false, error: e.toString() });
  }
}

function getFiles(data) {
  try {
    const folder = DriveApp.getFolderById(data.folderId);
    const files = folder.getFiles();
    const names = [], sizes = [], urls = [], dates = [], ids = [];

    while (files.hasNext()) {
      const file = files.next();
      names.push(file.getName());
      sizes.push(file.getSize());
      ids.push(file.getId());
      urls.push("https://drive.google.com/uc?export=download&id=" + file.getId());
      dates.push(file.getLastUpdated().toISOString());
    }

    return output({
      success: true,
      fileNames: names,
      fileSizes: sizes,
      fileUrls: urls,
      lastUpdateDates: dates,
      fileIds: ids
    });
  } catch (e) {
    return output({ success: false, error: e.toString() });
  }
}

I want to take image (using Camera) and upload it to google drive and then store that image url to google spread sheet. (spreadSheet setup done just need the url to do this)

For this I need to collect uploaded image url (drive URL)

** And also want to set progress bar to show image upload progress.


You can use this block for generate direct link of image .

You can use Progress event
OnProgress_Event

Please update the extension as I reupload it.

What is the fileID? where to find it?

FileCreated_Event