What is the process for obtaining a direct link to a file that has been uploaded using a

Can Google Apps Script provide a direct link to a file that has been uploaded to a Google Drive folder? Currently, I can only obtain a link to the folder itself where all files are saved.

This is the code I am using for file uploads:

function processForm(theForm) {
  try{
    var fileBlob1 = theForm.resumeFile;
    var fileBlob2 = theForm.piFile;

    var fldrSssn = DriveApp.getFolderById('My Folder ID');
    fldrSssn.createFile(fileBlob1);
    fldrSssn.createFile(fileBlob2);
    return fldrSssn.getUrl();

  }catch(e) {
      Logger.log(e);
  }//End catch
}

Answer №1

Before proceeding, ensure to store the File object obtained from the Folder.createFile() method, then utilize it to fetch the file URL.

function handleFormData(formData) {
  try{
    var resumeBlob = formData.resumeFile;
    var piBlob = formData.piFile;

    var workingFolder = DriveApp.getFolderById('My Unique Folder ID');
    var file1 = workingFolder.createFile(resumeBlob);
    var file2 = workingFolder.createFile(piBlob);

    // Consolidate all URLs into a single object
    return { 
      folderURL: workingFolder.getUrl(),
      file1URL: file1.getUrl(),
      file2URL: file2.getUrl()
    };

  }catch(error) {
      Logger.log(error);
  }// End of catch block
}

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Customize React JS Material UI's InputBase to be responsive

https://i.stack.imgur.com/9iHM1.gif Link: codesandbox Upon reaching a certain threshold, like on mobile devices, the elements inside should stack vertically instead of horizontally, taking up full length individually. How can this be achieved? ...

What should you do when you need to send a message from a website to an MQTT broker that lacks Websockets support?

Currently venturing into the realm of web development, I find myself tackling a project that involves sending messages from my website to Thingstream, an MQTT broker. My initial attempt using the MQTT Paho JavaScript library was thwarted by the fact that ...

Can the URL in angular.js be modified without having to invoke the controller

My current issue involves the following scenario: I am using the url http://localhost:8080/#/dashboard to display features in my dashboard. For instance, when the url changes to http://localhost:8080/#/dashboard/20, I need to load cities where the country ...

Attempting to abbreviate repetitive Javascript instructions

I have this functional javascript code, but I feel like there might be a more efficient way to write it. Any suggestions on simplifying this? let searchTerm = 'Some search text'; const isMatch = entry.title.toLowerCase().includes(searchTer ...

TypeScript maintains the reference and preserves the equality of two objects

Retrieve the last element of an array, make changes to the object that received the value, but inadvertently modify the original last position as well, resulting in both objects being identical. const lunchVisit = plannedVisits[plannedVisits.length ...

Methods in JavaScriptInterface not identified (WebView on Android)

In my MainActivity, I have the following code: webView.addJavascriptInterface( new JavaScriptInterface( this ), "ajaxHandler" ); .... public class JavaScriptInterface { Context mContext; JavaScriptInterface( Context c ) { ...

Incorporating React components into your current Django project

My goal is to enhance the interactivity of a specific part of my Django website by incorporating React components into the template HTML file. Instead of replacing the entire template with React, I want to focus on integrating React for its ease in handlin ...

Determining the availability of a remote source in React: A step-by-step guide

Is there a way to verify the existence of a remote resource, such as a large zip file, without actually downloading the file? What is the most efficient method for checking the presence of the resource? ...

Utilize identical animations across various elements

I have a canvas animation in JavaScript that is currently limited to one canvas element with the id "stars". I want to be able to use this animation multiple times without repeating the code. Is there a way to add a class for the canvas elements instead of ...

What materials are required in order to receive messages and information through my Contact page?

Currently, I am pondering the optimal method for gathering information from my Contact page. I have already created a form; however, I'm unsure how to send the gathered data to myself since I am relatively new to Web development. Angular is the framew ...

Implementing nested popup windows using Bootstrap

I am facing an issue with my two-page sign-in and sign-up setup in the header of my angular2 project. On the sign-up page, I have a link that should redirect to the sign-in page when clicked, but I am struggling to make it work. Can someone provide guidanc ...

The JavaScript Ajax data is in array format, however, the length of the array

I received the following Json data: (Extracted from the console) jsonData Object {0: Object, 1: Object, 2: Object, 3: Object, 4: Object, 5: Object, 7: Object} When I enter jsonData[0] in the console, this is the output: Object {id: 125, Module_id: 2, a ...

Ensuring that EJS IF/ELSE statements are evaluated accurately

I am encountering an issue where my variable 'answer' is returning the string 'success' and displaying correctly in the view. However, the IF/ELSE statement always seems to evaluate to the ELSE condition and displays 'no' inst ...

transferring information from Facebook to a web address through ZAPIER

Looking for guidance on sending data from Zapier to FB lead fetch. Is there a direct way to do this or is an external PHP file necessary? I need to extract name and email and send it to my CRM that is not supported by Zapier, but can receive data through U ...

Rails encountered a syntax error while attempting to parse JSON data, due to an unexpected character found at line 2, column 1

I'm a beginner when it comes to using AJAX in Ruby on Rails. What I'm trying to achieve is that when a user clicks on a link with the class .link (redirecting to an external site, for example www.google.de), it should send data - specifically the ...

Middleware GPS server - store location and transmit information to the server

After encountering a roadblock with my chosen GPS tracker service not supporting iframe plugins to share my car's position on my website, I've come up with the idea of creating a middleware server. The plan is to gather data from my GPS device, s ...

Continuously executing a series of JQuery functions or iterating through them repeatedly

Struggling with a jQuery animation loop issue that has me stuck. I need the animation to repeat continuously, but it's not working despite trying setInterval. Can anyone assist? Here's the fiddle link: https://jsfiddle.net/8v5feL9u/ $(document). ...

Getting a file object with v-file-input in Nuxt.js

For my Nuxt.Js apps, I utilized Vuetify.js as the UI framework. In order to obtain the file object when uploading files, I incorporated the v-file-input component from Vuetify.js and wrote the following code snippet: <template> <div> ...

Resolving promises in a sequential manner can lead to encountering errors along

Currently, I've been attempting to iterate through an array of IDs and pass them into a function (this.handleTransfer) that makes API calls. My goal is for the next iteration to only proceed when a response is received from the previous one. In my que ...

Can loading HTML and js through ajax be considered secure?

I am currently utilizing the Jquery load function $('#result').load('test.php'); in order to dynamically load a page within another page when clicking on a tab. The page being loaded contains javascript, php, and a form. Upon inspecting ...