jkushwaha commited on
Commit
bbce5b9
Β·
verified Β·
1 Parent(s): 06dd938

Delete at.js

Browse files
Files changed (1) hide show
  1. at.js +0 -48
at.js DELETED
@@ -1,48 +0,0 @@
1
- // ── Paste this entire file into Google Apps Script (script.google.com) ──────
2
- // Deploy as Web App: Execute as "Me", Access "Anyone"
3
- // ─────────────────────────────────────────────────────────────────────────────
4
-
5
- const FOLDER_NAME = "QA Testing Photos";
6
-
7
- function getFolder() {
8
- const it = DriveApp.getFoldersByName(FOLDER_NAME);
9
- return it.hasNext() ? it.next() : DriveApp.createFolder(FOLDER_NAME);
10
- }
11
-
12
- function doPost(e) {
13
- try {
14
- const req = JSON.parse(e.postData.contents);
15
-
16
- if (req.action === "upload") {
17
- const folder = getFolder();
18
- const base64Data = req.base64.replace(/^data:image\/\w+;base64,/, "");
19
- const bytes = Utilities.base64Decode(base64Data);
20
- const blob = Utilities.newBlob(bytes, req.mimeType || "image/jpeg", req.filename || "photo.jpg");
21
- const file = folder.createFile(blob);
22
- file.setSharing(DriveApp.Access.ANYONE_WITH_LINK, DriveApp.Permission.VIEW);
23
- return respond({
24
- fileId: file.getId(),
25
- url: "https://drive.google.com/uc?export=view&id=" + file.getId(),
26
- });
27
- }
28
-
29
- if (req.action === "delete") {
30
- try { DriveApp.getFileById(req.fileId).setTrashed(true); } catch (_) {}
31
- return respond({ success: true });
32
- }
33
-
34
- return respond({ error: "Unknown action" });
35
- } catch (err) {
36
- return respond({ error: err.message });
37
- }
38
- }
39
-
40
- function doGet() {
41
- return respond({ status: "ok" });
42
- }
43
-
44
- function respond(data) {
45
- return ContentService
46
- .createTextOutput(JSON.stringify(data))
47
- .setMimeType(ContentService.MimeType.JSON);
48
- }