Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

118
Vistas
create public folder and allow user to create files into the particular folder

I am creating an application using asp.net mvc and javascript in which I am creating folders and creating document inside those folders,

below is my code to create folders and docs

function createFolder() {
    loadClient('https://www.googleapis.com/discovery/v1/apis/drive/v3/rest', function () {
        var body = {
            'name': document.getElementById('txtFolderName').value,
            'mimeType': "application/vnd.google-apps.folder",
            'parents': ['1R7c6lCV_qRxSTVHnbefLN4vJY0ZTMFUW']
        };

        return gapi.client.drive.files.create({
            'resource': body
        }).then(function (response) {
            console.log("Response", response);
        }, function (err) { console.error("Execute error", err); });
    })
}

function execute() {
    loadClient('https://docs.googleapis.com/$discovery/rest?version=v1', function () {
        return gapi.client.docs.documents.create({
            "resource": {
                "title": document.getElementById('txtTitle').value
            }
        })
            .then(function (response) {
                // Handle the results here (response.result has the parsed body).
                console.log("Response", response);
            },
                function (err) { console.error("Execute error", err); });
    })
}

now I want to create folders which will be accessible to everyone of my organization and insert the file in those folder

for example I have folder Named as "My company" and when I create a file, the file should be created inside "My company" folder

thanks for your time

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

I believe your goal is as follows.

  • You want to create a new folder and want to publicly share the created folder as the writer.
  • You want to achieve this using googleapis for Javascript.

In this case, how about the following modification?

Modified script:

From:

return gapi.client.drive.files.create({
    'resource': body
}).then(function (response) {
    console.log("Response", response);
}, function (err) { console.error("Execute error", err); });

To:

gapi.client.drive.files.create({ 'resource': body })
.then(function (response) {
  console.log("Response", response);

  // Created folder is publicly shared.
  var folderId = response.result.id;
  gapi.client.drive.permissions.create({
    "fileId": folderId,
    "resource": {"role": "writer", "type": "anyone" }
  })
  .then(function (res) {
    console.log(res);
  }, function (err) {
    console.log(err.result.error.message);
  });

  // Create new Google Document to the created folder.
  var body = {
    'name': "sample filename",
    'mimeType': "application/vnd.google-apps.document",
    'parents': [folderId]
  };
  gapi.client.drive.files.create({ 'resource': body })
  .then(function (res) {
    console.log(res);
  }, function (err) {
    console.log(err.result.error.message);
  });

}, function (err) {
  console.error("Execute error", err);
});
  • I added the script for one more thing I want to achieve is that I want to create document in those a particular folder of my google drive.

Reference:

  • Permissions: create
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda