NodeJS Google Drive API how to update fileHow can I update NodeJS and NPM to the next versions?How do I update Node.js?Displaying files (e.g. images) stored in Google Drive on a websitechange Google Drive mimeType on update fileHow do I update each dependency in package.json to the latest version?Why is the response to gapi.client.drive.realtime.get empty?how to upload file to google drive using sdk in uploadtype=mediaGoogle Apiclient, Google Drive, after uploaded file emptyGoogle drive API 403 insufficent permission error (do I need a google for work account?)node.js / google drive sdk v3: access to webContentLink (and all image metadata)

Using “sparkling” as a diminutive of “spark” in a poem

How can I get more energy without spending coins?

Why do some professors with PhDs leave their professorships to teach high school?

What are the penalties for overstaying in USA?

How to perform Login Authentication at the client-side?

How well known and how commonly used was Huffman coding in 1979?

Why is Madam Hooch not a professor?

Can ADFS connect to other SSO services?

Analog is Obtuse!

Do French speakers not use the subjunctive informally?

C-152 carb heat on before landing in hot weather?

Should I hide continue button until tasks are completed?

Is there any set of 2-6 notes that doesn't have a chord name?

Should I tell my insurance company I'm making payments on my new car?

STM Microcontroller burns every time

Is there any evidence that the small canisters (10 liters) of 95% oxygen actually help with altitude sickness?

Fetch and print all properties of an object graph as string

Is it damaging to turn off a small fridge for two days every week?

What happens when your group is victim of a surprise attack but you can't be surprised?

Why do textbooks often include the solutions to odd or even numbered problems but not both?

Why aren't (poly-)cotton tents more popular?

Character discovers anti gravity emitters, flies a shipping container into space and docks with space station

Why doesn't a marching band have strings?

Links to webpages in books



NodeJS Google Drive API how to update file


How can I update NodeJS and NPM to the next versions?How do I update Node.js?Displaying files (e.g. images) stored in Google Drive on a websitechange Google Drive mimeType on update fileHow do I update each dependency in package.json to the latest version?Why is the response to gapi.client.drive.realtime.get empty?how to upload file to google drive using sdk in uploadtype=mediaGoogle Apiclient, Google Drive, after uploaded file emptyGoogle drive API 403 insufficent permission error (do I need a google for work account?)node.js / google drive sdk v3: access to webContentLink (and all image metadata)






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








0















Hi I'm trying to update a Google Doc with NodeJS using the Google Drive API and I'm getting this error:




"error":
"code": 500,
"message": null




Here's the relevant code :



var j = new google.auth.JWT(
creds.client_email,
null,
creds.private_key,
[
"https://www.googleapis.com/auth/drive"
]
);
async function refreshTokens()
startedWaiting = true;
return j.authorize((r,t) =>
startedWaiting = false;
timeTillNeedRefresh = t["expiry_date"] - Date.now();
setTimeout(function()
refreshTokens();
// console.log("doing Q", Q);

, timeTillNeedRefresh);

tokens = t;
console.log("GOT A TOKEN", tokens);
Q.forEach(x=>x());
Q = [];

);


async function start()
await refreshTokens();

start();
function myFetch(opts) empty;
var headers =
'Accept-Encoding': 'gzip',
'User-Agent': 'google-api-nodejs-client/0.7.2 (gzip)',
Authorization:tokens.token_type +" "+ tokens.access_token,
Accept:"application/json"
;
if(opts.headers)
for(k in opts.headers)
headers[k] = opts.headers[k];


fetch(
opts.url


updateFile(
id: "1vebqOamZ9QB4HqfUaQN-U9Zt4y33eij-I21glMvaPVQ",
content: "hi there"
);

async function allFuncs(tmp)
if(tokens === null)
console.log("DOING it later")
Q.push(tmp);
await refreshTokens();
else if(startedWaiting

async function updateFile(opts)


I tried looking up what this error means but I couldn't find anything related to nodejs...
Does anyone know if its a header issue or is there any way to fix it?



I don't know if its possible to do wih a service key, or if you HAVE to verify the user in order to do so??



SEEMINGLY if the service key email has edit permissions for the file, it should just be able to edit it at will.










share|improve this question
























  • In order to correctly your situation, can I ask you about your question? 1. Do you want to overwrite Google Document by a text of hi there? 2. Is the Google Document shared with the Service Account? 3. Can you use googleapis of Node.js? 4. Are you required to use only Drive API? For example, how about using Google Docs API?

    – Tanaike
    Mar 30 at 0:17











  • @Tanaike Yes, Yes, Yes, and I'm currently just using the drive API I didn't know there was a difference between the doc and drive API nowadays, I could use anything I need

    – bluejayke
    Mar 30 at 0:36











  • Thank you for replying. I could understand about your question. I proposed a sample script as an answer. Could you please confirm it? If this was not the result you want, I apologize.

    – Tanaike
    Mar 30 at 1:16











  • Did my answer show you the result what you want? Would you please tell me about it? That is also useful for me to study. If this works, other people who have the same issue with you can also base your question as a question which can be solved. If you have issues for my answer yet, I apologize. At that time, can I ask you about your current situation? I would like to study to solve your issues.

    – Tanaike
    Apr 1 at 22:35











  • @Tanaike Yes, although I did say that I can use the googleAPI, but I neglected to mentioned that I would be interested in doing it without it; just by using GET requests, do you know how to do that?

    – bluejayke
    Apr 1 at 23:31

















0















Hi I'm trying to update a Google Doc with NodeJS using the Google Drive API and I'm getting this error:




"error":
"code": 500,
"message": null




Here's the relevant code :



var j = new google.auth.JWT(
creds.client_email,
null,
creds.private_key,
[
"https://www.googleapis.com/auth/drive"
]
);
async function refreshTokens()
startedWaiting = true;
return j.authorize((r,t) =>
startedWaiting = false;
timeTillNeedRefresh = t["expiry_date"] - Date.now();
setTimeout(function()
refreshTokens();
// console.log("doing Q", Q);

, timeTillNeedRefresh);

tokens = t;
console.log("GOT A TOKEN", tokens);
Q.forEach(x=>x());
Q = [];

);


async function start()
await refreshTokens();

start();
function myFetch(opts) empty;
var headers =
'Accept-Encoding': 'gzip',
'User-Agent': 'google-api-nodejs-client/0.7.2 (gzip)',
Authorization:tokens.token_type +" "+ tokens.access_token,
Accept:"application/json"
;
if(opts.headers)
for(k in opts.headers)
headers[k] = opts.headers[k];


fetch(
opts.url


updateFile(
id: "1vebqOamZ9QB4HqfUaQN-U9Zt4y33eij-I21glMvaPVQ",
content: "hi there"
);

async function allFuncs(tmp)
if(tokens === null)
console.log("DOING it later")
Q.push(tmp);
await refreshTokens();
else if(startedWaiting

async function updateFile(opts)


I tried looking up what this error means but I couldn't find anything related to nodejs...
Does anyone know if its a header issue or is there any way to fix it?



I don't know if its possible to do wih a service key, or if you HAVE to verify the user in order to do so??



SEEMINGLY if the service key email has edit permissions for the file, it should just be able to edit it at will.










share|improve this question
























  • In order to correctly your situation, can I ask you about your question? 1. Do you want to overwrite Google Document by a text of hi there? 2. Is the Google Document shared with the Service Account? 3. Can you use googleapis of Node.js? 4. Are you required to use only Drive API? For example, how about using Google Docs API?

    – Tanaike
    Mar 30 at 0:17











  • @Tanaike Yes, Yes, Yes, and I'm currently just using the drive API I didn't know there was a difference between the doc and drive API nowadays, I could use anything I need

    – bluejayke
    Mar 30 at 0:36











  • Thank you for replying. I could understand about your question. I proposed a sample script as an answer. Could you please confirm it? If this was not the result you want, I apologize.

    – Tanaike
    Mar 30 at 1:16











  • Did my answer show you the result what you want? Would you please tell me about it? That is also useful for me to study. If this works, other people who have the same issue with you can also base your question as a question which can be solved. If you have issues for my answer yet, I apologize. At that time, can I ask you about your current situation? I would like to study to solve your issues.

    – Tanaike
    Apr 1 at 22:35











  • @Tanaike Yes, although I did say that I can use the googleAPI, but I neglected to mentioned that I would be interested in doing it without it; just by using GET requests, do you know how to do that?

    – bluejayke
    Apr 1 at 23:31













0












0








0


0






Hi I'm trying to update a Google Doc with NodeJS using the Google Drive API and I'm getting this error:




"error":
"code": 500,
"message": null




Here's the relevant code :



var j = new google.auth.JWT(
creds.client_email,
null,
creds.private_key,
[
"https://www.googleapis.com/auth/drive"
]
);
async function refreshTokens()
startedWaiting = true;
return j.authorize((r,t) =>
startedWaiting = false;
timeTillNeedRefresh = t["expiry_date"] - Date.now();
setTimeout(function()
refreshTokens();
// console.log("doing Q", Q);

, timeTillNeedRefresh);

tokens = t;
console.log("GOT A TOKEN", tokens);
Q.forEach(x=>x());
Q = [];

);


async function start()
await refreshTokens();

start();
function myFetch(opts) empty;
var headers =
'Accept-Encoding': 'gzip',
'User-Agent': 'google-api-nodejs-client/0.7.2 (gzip)',
Authorization:tokens.token_type +" "+ tokens.access_token,
Accept:"application/json"
;
if(opts.headers)
for(k in opts.headers)
headers[k] = opts.headers[k];


fetch(
opts.url


updateFile(
id: "1vebqOamZ9QB4HqfUaQN-U9Zt4y33eij-I21glMvaPVQ",
content: "hi there"
);

async function allFuncs(tmp)
if(tokens === null)
console.log("DOING it later")
Q.push(tmp);
await refreshTokens();
else if(startedWaiting

async function updateFile(opts)


I tried looking up what this error means but I couldn't find anything related to nodejs...
Does anyone know if its a header issue or is there any way to fix it?



I don't know if its possible to do wih a service key, or if you HAVE to verify the user in order to do so??



SEEMINGLY if the service key email has edit permissions for the file, it should just be able to edit it at will.










share|improve this question
















Hi I'm trying to update a Google Doc with NodeJS using the Google Drive API and I'm getting this error:




"error":
"code": 500,
"message": null




Here's the relevant code :



var j = new google.auth.JWT(
creds.client_email,
null,
creds.private_key,
[
"https://www.googleapis.com/auth/drive"
]
);
async function refreshTokens()
startedWaiting = true;
return j.authorize((r,t) =>
startedWaiting = false;
timeTillNeedRefresh = t["expiry_date"] - Date.now();
setTimeout(function()
refreshTokens();
// console.log("doing Q", Q);

, timeTillNeedRefresh);

tokens = t;
console.log("GOT A TOKEN", tokens);
Q.forEach(x=>x());
Q = [];

);


async function start()
await refreshTokens();

start();
function myFetch(opts) empty;
var headers =
'Accept-Encoding': 'gzip',
'User-Agent': 'google-api-nodejs-client/0.7.2 (gzip)',
Authorization:tokens.token_type +" "+ tokens.access_token,
Accept:"application/json"
;
if(opts.headers)
for(k in opts.headers)
headers[k] = opts.headers[k];


fetch(
opts.url


updateFile(
id: "1vebqOamZ9QB4HqfUaQN-U9Zt4y33eij-I21glMvaPVQ",
content: "hi there"
);

async function allFuncs(tmp)
if(tokens === null)
console.log("DOING it later")
Q.push(tmp);
await refreshTokens();
else if(startedWaiting

async function updateFile(opts)


I tried looking up what this error means but I couldn't find anything related to nodejs...
Does anyone know if its a header issue or is there any way to fix it?



I don't know if its possible to do wih a service key, or if you HAVE to verify the user in order to do so??



SEEMINGLY if the service key email has edit permissions for the file, it should just be able to edit it at will.







node.js google-drive-api google-apis-explorer






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 25 at 18:53









John

3163 silver badges9 bronze badges




3163 silver badges9 bronze badges










asked Mar 25 at 10:26









bluejaykebluejayke

5852 gold badges6 silver badges21 bronze badges




5852 gold badges6 silver badges21 bronze badges












  • In order to correctly your situation, can I ask you about your question? 1. Do you want to overwrite Google Document by a text of hi there? 2. Is the Google Document shared with the Service Account? 3. Can you use googleapis of Node.js? 4. Are you required to use only Drive API? For example, how about using Google Docs API?

    – Tanaike
    Mar 30 at 0:17











  • @Tanaike Yes, Yes, Yes, and I'm currently just using the drive API I didn't know there was a difference between the doc and drive API nowadays, I could use anything I need

    – bluejayke
    Mar 30 at 0:36











  • Thank you for replying. I could understand about your question. I proposed a sample script as an answer. Could you please confirm it? If this was not the result you want, I apologize.

    – Tanaike
    Mar 30 at 1:16











  • Did my answer show you the result what you want? Would you please tell me about it? That is also useful for me to study. If this works, other people who have the same issue with you can also base your question as a question which can be solved. If you have issues for my answer yet, I apologize. At that time, can I ask you about your current situation? I would like to study to solve your issues.

    – Tanaike
    Apr 1 at 22:35











  • @Tanaike Yes, although I did say that I can use the googleAPI, but I neglected to mentioned that I would be interested in doing it without it; just by using GET requests, do you know how to do that?

    – bluejayke
    Apr 1 at 23:31

















  • In order to correctly your situation, can I ask you about your question? 1. Do you want to overwrite Google Document by a text of hi there? 2. Is the Google Document shared with the Service Account? 3. Can you use googleapis of Node.js? 4. Are you required to use only Drive API? For example, how about using Google Docs API?

    – Tanaike
    Mar 30 at 0:17











  • @Tanaike Yes, Yes, Yes, and I'm currently just using the drive API I didn't know there was a difference between the doc and drive API nowadays, I could use anything I need

    – bluejayke
    Mar 30 at 0:36











  • Thank you for replying. I could understand about your question. I proposed a sample script as an answer. Could you please confirm it? If this was not the result you want, I apologize.

    – Tanaike
    Mar 30 at 1:16











  • Did my answer show you the result what you want? Would you please tell me about it? That is also useful for me to study. If this works, other people who have the same issue with you can also base your question as a question which can be solved. If you have issues for my answer yet, I apologize. At that time, can I ask you about your current situation? I would like to study to solve your issues.

    – Tanaike
    Apr 1 at 22:35











  • @Tanaike Yes, although I did say that I can use the googleAPI, but I neglected to mentioned that I would be interested in doing it without it; just by using GET requests, do you know how to do that?

    – bluejayke
    Apr 1 at 23:31
















In order to correctly your situation, can I ask you about your question? 1. Do you want to overwrite Google Document by a text of hi there? 2. Is the Google Document shared with the Service Account? 3. Can you use googleapis of Node.js? 4. Are you required to use only Drive API? For example, how about using Google Docs API?

– Tanaike
Mar 30 at 0:17





In order to correctly your situation, can I ask you about your question? 1. Do you want to overwrite Google Document by a text of hi there? 2. Is the Google Document shared with the Service Account? 3. Can you use googleapis of Node.js? 4. Are you required to use only Drive API? For example, how about using Google Docs API?

– Tanaike
Mar 30 at 0:17













@Tanaike Yes, Yes, Yes, and I'm currently just using the drive API I didn't know there was a difference between the doc and drive API nowadays, I could use anything I need

– bluejayke
Mar 30 at 0:36





@Tanaike Yes, Yes, Yes, and I'm currently just using the drive API I didn't know there was a difference between the doc and drive API nowadays, I could use anything I need

– bluejayke
Mar 30 at 0:36













Thank you for replying. I could understand about your question. I proposed a sample script as an answer. Could you please confirm it? If this was not the result you want, I apologize.

– Tanaike
Mar 30 at 1:16





Thank you for replying. I could understand about your question. I proposed a sample script as an answer. Could you please confirm it? If this was not the result you want, I apologize.

– Tanaike
Mar 30 at 1:16













Did my answer show you the result what you want? Would you please tell me about it? That is also useful for me to study. If this works, other people who have the same issue with you can also base your question as a question which can be solved. If you have issues for my answer yet, I apologize. At that time, can I ask you about your current situation? I would like to study to solve your issues.

– Tanaike
Apr 1 at 22:35





Did my answer show you the result what you want? Would you please tell me about it? That is also useful for me to study. If this works, other people who have the same issue with you can also base your question as a question which can be solved. If you have issues for my answer yet, I apologize. At that time, can I ask you about your current situation? I would like to study to solve your issues.

– Tanaike
Apr 1 at 22:35













@Tanaike Yes, although I did say that I can use the googleAPI, but I neglected to mentioned that I would be interested in doing it without it; just by using GET requests, do you know how to do that?

– bluejayke
Apr 1 at 23:31





@Tanaike Yes, although I did say that I can use the googleAPI, but I neglected to mentioned that I would be interested in doing it without it; just by using GET requests, do you know how to do that?

– bluejayke
Apr 1 at 23:31












1 Answer
1






active

oldest

votes


















0














  • You want to overwrite the existing Google Document by a text of hi there with Drive API using Service Account.

  • The Google Document is shared with the Service Account.

  • You can use googleapis.

I could understand like above. If my understanding is correct, how about this sample script? In this sample script, I used the files.update method of Drive API.



Sample script:



Before you run the script, please set the json file path downloaded when the Service Account is created. And please confirm the file ID of Google Document, again.



const stream = require('stream');
const google = require('googleapis');
const creds = require('###'); // Please set the json file path downloaded when the Service Account is created.
const jwtClient = new google.auth.JWT(
creds.client_email,
null,
creds.private_key,
['https://www.googleapis.com/auth/drive'],
null
);

const id = "1vebqOamZ9QB4HqfUaQN-U9Zt4y33eij-I21glMvaPVQ"; // Please set the file ID of Google Document
const content = "hi there"; // Please set the text.

const drive = google.drive(version: 'v3', auth: jwtClient);
const buf = new Buffer(content, 'binary');
const buffer = Uint8Array.from(buf);
var bufferStream = new stream.PassThrough();
bufferStream.end(buffer);
const media =
mimeType: 'application/vnd.google-apps.document',
body: bufferStream,
;
drive.files.update(
fileId: id,
media: media,
, (err, res) =>
if (err)
console.log(err);
return;

console.log(res.data);
);


Note:



  • When you run the script, the existing Google Document is overwritten. So please be careful this. I recommend to use a sample Document for testing.

  • If this script didn't work, please confirm the following points.

    1. Drive API is enabled at API console.

    2. The Service Account can be used.

    3. The Google Document is shared with the Service Account.

    4. The version of googleapis is the latest one.


Reference:



  • Files: update

Edit:



  • You don't want to use googleapis.

  • You want to overwrite Google Document with a text value without using googleapis.

From your comments, I understood like above. If my understanding is correct, how about this sample script? When you run this script, please confirm the following points.



  1. About the script,

    • Please set privateKey and clientEmail from JSON file of Service Account.

    • Please set the file ID of the existing Google Document you want to overwrite.


  2. Drive API is enabled at API console.

  3. The Service Account can be used.

  4. The Google Document is shared with the Service Account.

  5. The version of googleapis is the latest one.

Sample script:



const cryptor = require('crypto');
const request = require('request');

// Get access token using Service Account
function getAccessToken(serviceAccount)
const scopes = ["https://www.googleapis.com/auth/drive"];
const url = "https://www.googleapis.com/oauth2/v4/token";
const header =
alg: "RS256",
typ: "JWT",
;
const now = Math.floor(Date.now() / 1000);
const claim =
iss: serviceAccount.clientEmail,
scope: scopes.join(" "),
aud: url,
exp: (now + 3600).toString(),
iat: now.toString(),
;
const signature = Buffer.from(JSON.stringify(header)).toString('base64') + "." + Buffer.from(JSON.stringify(claim)).toString('base64');
var sign = cryptor.createSign('RSA-SHA256');
sign.update(signature);
const jwt = signature + "." + sign.sign(serviceAccount.privateKey, 'base64');
return new Promise(function(resolve, reject)
request(
method: "post",
url: url,
body: JSON.stringify(
assertion: jwt,
grant_type: "urn:ietf:params:oauth:grant-type:jwt-bearer",
),
, (err, res, body) =>
if (err)
console.log(err);
return;

const obj = JSON.parse(body);
resolve(obj.access_token);
);
);


// Overwrite file in Google Drive
function overWriting(object)
const metadata =
mimeType: "application/vnd.google-apps.document",
;
const url = "https://www.googleapis.com/upload/drive/v3/files/" + object.googleDocumentFileId + "?uploadType=multipart";
const boundary = "xxxxxxxxxxx";
var data = "--" + boundary + "rn";
data += "Content-Disposition: form-data; name="metadata"rn";
data += "Content-Type: application/json; charset=UTF-8rnrn";
data += JSON.stringify(metadata) + "rn";
data += "--" + boundary + "rn";
data += "Content-Disposition: form-data; name="file"; filename="sample.txt"rn";
data += "Content-Type: text/plain" + "rnrn";
const payload = Buffer.concat([
Buffer.from(data, "utf8"),
new Buffer(object.textData, 'binary'),
Buffer.from("rn--" + boundary + "--", "utf8"),
]);
const options =
method: 'patch',
url: url,
headers:
"Content-Type": "multipart/related; boundary=" + boundary,
'Authorization': 'Bearer ' + object.accessToken,
,
body: payload,
;
request(options, (error, response, body) =>
console.log(body);
);



async function main()
const serviceAccount =
privateKey: "###", // private_key of JSON file retrieved by creating Service Account
clientEmail: "###", // client_email of JSON file retrieved by creating Service Account
;
var object =
googleDocumentFileId: "###", // Set the file ID of the existing Google Document
textData: "hi there",
;
const accessToken = await getAccessToken(serviceAccount);
if (accessToken)
object.accessToken = accessToken;
overWriting(object);



main();





share|improve this answer

























  • @bluejayke I understood that you want to overwrite Google Document with a text value without using googleapis. For this situation, I added a sample script. Could you please confirm it? If this was not what you want, I apologize.

    – Tanaike
    Apr 2 at 7:54











  • @bluejayke Did my additional sample script show you the result what you want? Would you please tell me about it? That is also useful for me to study. If you have issues for my answer yet, I apologize. At that time, can I ask you about your current situation? I would like to study to solve your issues.

    – Tanaike
    Apr 4 at 0:59











  • @bluejayke Is there anything that I can do for your question? If my answer was not useful for your situation. I have to apologize and modify it. If you can cooperate to resolve your issue, I'm glad. I would like to think of about the solution.

    – Tanaike
    Apr 6 at 1:58













Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55335703%2fnodejs-google-drive-api-how-to-update-file%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














  • You want to overwrite the existing Google Document by a text of hi there with Drive API using Service Account.

  • The Google Document is shared with the Service Account.

  • You can use googleapis.

I could understand like above. If my understanding is correct, how about this sample script? In this sample script, I used the files.update method of Drive API.



Sample script:



Before you run the script, please set the json file path downloaded when the Service Account is created. And please confirm the file ID of Google Document, again.



const stream = require('stream');
const google = require('googleapis');
const creds = require('###'); // Please set the json file path downloaded when the Service Account is created.
const jwtClient = new google.auth.JWT(
creds.client_email,
null,
creds.private_key,
['https://www.googleapis.com/auth/drive'],
null
);

const id = "1vebqOamZ9QB4HqfUaQN-U9Zt4y33eij-I21glMvaPVQ"; // Please set the file ID of Google Document
const content = "hi there"; // Please set the text.

const drive = google.drive(version: 'v3', auth: jwtClient);
const buf = new Buffer(content, 'binary');
const buffer = Uint8Array.from(buf);
var bufferStream = new stream.PassThrough();
bufferStream.end(buffer);
const media =
mimeType: 'application/vnd.google-apps.document',
body: bufferStream,
;
drive.files.update(
fileId: id,
media: media,
, (err, res) =>
if (err)
console.log(err);
return;

console.log(res.data);
);


Note:



  • When you run the script, the existing Google Document is overwritten. So please be careful this. I recommend to use a sample Document for testing.

  • If this script didn't work, please confirm the following points.

    1. Drive API is enabled at API console.

    2. The Service Account can be used.

    3. The Google Document is shared with the Service Account.

    4. The version of googleapis is the latest one.


Reference:



  • Files: update

Edit:



  • You don't want to use googleapis.

  • You want to overwrite Google Document with a text value without using googleapis.

From your comments, I understood like above. If my understanding is correct, how about this sample script? When you run this script, please confirm the following points.



  1. About the script,

    • Please set privateKey and clientEmail from JSON file of Service Account.

    • Please set the file ID of the existing Google Document you want to overwrite.


  2. Drive API is enabled at API console.

  3. The Service Account can be used.

  4. The Google Document is shared with the Service Account.

  5. The version of googleapis is the latest one.

Sample script:



const cryptor = require('crypto');
const request = require('request');

// Get access token using Service Account
function getAccessToken(serviceAccount)
const scopes = ["https://www.googleapis.com/auth/drive"];
const url = "https://www.googleapis.com/oauth2/v4/token";
const header =
alg: "RS256",
typ: "JWT",
;
const now = Math.floor(Date.now() / 1000);
const claim =
iss: serviceAccount.clientEmail,
scope: scopes.join(" "),
aud: url,
exp: (now + 3600).toString(),
iat: now.toString(),
;
const signature = Buffer.from(JSON.stringify(header)).toString('base64') + "." + Buffer.from(JSON.stringify(claim)).toString('base64');
var sign = cryptor.createSign('RSA-SHA256');
sign.update(signature);
const jwt = signature + "." + sign.sign(serviceAccount.privateKey, 'base64');
return new Promise(function(resolve, reject)
request(
method: "post",
url: url,
body: JSON.stringify(
assertion: jwt,
grant_type: "urn:ietf:params:oauth:grant-type:jwt-bearer",
),
, (err, res, body) =>
if (err)
console.log(err);
return;

const obj = JSON.parse(body);
resolve(obj.access_token);
);
);


// Overwrite file in Google Drive
function overWriting(object)
const metadata =
mimeType: "application/vnd.google-apps.document",
;
const url = "https://www.googleapis.com/upload/drive/v3/files/" + object.googleDocumentFileId + "?uploadType=multipart";
const boundary = "xxxxxxxxxxx";
var data = "--" + boundary + "rn";
data += "Content-Disposition: form-data; name="metadata"rn";
data += "Content-Type: application/json; charset=UTF-8rnrn";
data += JSON.stringify(metadata) + "rn";
data += "--" + boundary + "rn";
data += "Content-Disposition: form-data; name="file"; filename="sample.txt"rn";
data += "Content-Type: text/plain" + "rnrn";
const payload = Buffer.concat([
Buffer.from(data, "utf8"),
new Buffer(object.textData, 'binary'),
Buffer.from("rn--" + boundary + "--", "utf8"),
]);
const options =
method: 'patch',
url: url,
headers:
"Content-Type": "multipart/related; boundary=" + boundary,
'Authorization': 'Bearer ' + object.accessToken,
,
body: payload,
;
request(options, (error, response, body) =>
console.log(body);
);



async function main()
const serviceAccount =
privateKey: "###", // private_key of JSON file retrieved by creating Service Account
clientEmail: "###", // client_email of JSON file retrieved by creating Service Account
;
var object =
googleDocumentFileId: "###", // Set the file ID of the existing Google Document
textData: "hi there",
;
const accessToken = await getAccessToken(serviceAccount);
if (accessToken)
object.accessToken = accessToken;
overWriting(object);



main();





share|improve this answer

























  • @bluejayke I understood that you want to overwrite Google Document with a text value without using googleapis. For this situation, I added a sample script. Could you please confirm it? If this was not what you want, I apologize.

    – Tanaike
    Apr 2 at 7:54











  • @bluejayke Did my additional sample script show you the result what you want? Would you please tell me about it? That is also useful for me to study. If you have issues for my answer yet, I apologize. At that time, can I ask you about your current situation? I would like to study to solve your issues.

    – Tanaike
    Apr 4 at 0:59











  • @bluejayke Is there anything that I can do for your question? If my answer was not useful for your situation. I have to apologize and modify it. If you can cooperate to resolve your issue, I'm glad. I would like to think of about the solution.

    – Tanaike
    Apr 6 at 1:58















0














  • You want to overwrite the existing Google Document by a text of hi there with Drive API using Service Account.

  • The Google Document is shared with the Service Account.

  • You can use googleapis.

I could understand like above. If my understanding is correct, how about this sample script? In this sample script, I used the files.update method of Drive API.



Sample script:



Before you run the script, please set the json file path downloaded when the Service Account is created. And please confirm the file ID of Google Document, again.



const stream = require('stream');
const google = require('googleapis');
const creds = require('###'); // Please set the json file path downloaded when the Service Account is created.
const jwtClient = new google.auth.JWT(
creds.client_email,
null,
creds.private_key,
['https://www.googleapis.com/auth/drive'],
null
);

const id = "1vebqOamZ9QB4HqfUaQN-U9Zt4y33eij-I21glMvaPVQ"; // Please set the file ID of Google Document
const content = "hi there"; // Please set the text.

const drive = google.drive(version: 'v3', auth: jwtClient);
const buf = new Buffer(content, 'binary');
const buffer = Uint8Array.from(buf);
var bufferStream = new stream.PassThrough();
bufferStream.end(buffer);
const media =
mimeType: 'application/vnd.google-apps.document',
body: bufferStream,
;
drive.files.update(
fileId: id,
media: media,
, (err, res) =>
if (err)
console.log(err);
return;

console.log(res.data);
);


Note:



  • When you run the script, the existing Google Document is overwritten. So please be careful this. I recommend to use a sample Document for testing.

  • If this script didn't work, please confirm the following points.

    1. Drive API is enabled at API console.

    2. The Service Account can be used.

    3. The Google Document is shared with the Service Account.

    4. The version of googleapis is the latest one.


Reference:



  • Files: update

Edit:



  • You don't want to use googleapis.

  • You want to overwrite Google Document with a text value without using googleapis.

From your comments, I understood like above. If my understanding is correct, how about this sample script? When you run this script, please confirm the following points.



  1. About the script,

    • Please set privateKey and clientEmail from JSON file of Service Account.

    • Please set the file ID of the existing Google Document you want to overwrite.


  2. Drive API is enabled at API console.

  3. The Service Account can be used.

  4. The Google Document is shared with the Service Account.

  5. The version of googleapis is the latest one.

Sample script:



const cryptor = require('crypto');
const request = require('request');

// Get access token using Service Account
function getAccessToken(serviceAccount)
const scopes = ["https://www.googleapis.com/auth/drive"];
const url = "https://www.googleapis.com/oauth2/v4/token";
const header =
alg: "RS256",
typ: "JWT",
;
const now = Math.floor(Date.now() / 1000);
const claim =
iss: serviceAccount.clientEmail,
scope: scopes.join(" "),
aud: url,
exp: (now + 3600).toString(),
iat: now.toString(),
;
const signature = Buffer.from(JSON.stringify(header)).toString('base64') + "." + Buffer.from(JSON.stringify(claim)).toString('base64');
var sign = cryptor.createSign('RSA-SHA256');
sign.update(signature);
const jwt = signature + "." + sign.sign(serviceAccount.privateKey, 'base64');
return new Promise(function(resolve, reject)
request(
method: "post",
url: url,
body: JSON.stringify(
assertion: jwt,
grant_type: "urn:ietf:params:oauth:grant-type:jwt-bearer",
),
, (err, res, body) =>
if (err)
console.log(err);
return;

const obj = JSON.parse(body);
resolve(obj.access_token);
);
);


// Overwrite file in Google Drive
function overWriting(object)
const metadata =
mimeType: "application/vnd.google-apps.document",
;
const url = "https://www.googleapis.com/upload/drive/v3/files/" + object.googleDocumentFileId + "?uploadType=multipart";
const boundary = "xxxxxxxxxxx";
var data = "--" + boundary + "rn";
data += "Content-Disposition: form-data; name="metadata"rn";
data += "Content-Type: application/json; charset=UTF-8rnrn";
data += JSON.stringify(metadata) + "rn";
data += "--" + boundary + "rn";
data += "Content-Disposition: form-data; name="file"; filename="sample.txt"rn";
data += "Content-Type: text/plain" + "rnrn";
const payload = Buffer.concat([
Buffer.from(data, "utf8"),
new Buffer(object.textData, 'binary'),
Buffer.from("rn--" + boundary + "--", "utf8"),
]);
const options =
method: 'patch',
url: url,
headers:
"Content-Type": "multipart/related; boundary=" + boundary,
'Authorization': 'Bearer ' + object.accessToken,
,
body: payload,
;
request(options, (error, response, body) =>
console.log(body);
);



async function main()
const serviceAccount =
privateKey: "###", // private_key of JSON file retrieved by creating Service Account
clientEmail: "###", // client_email of JSON file retrieved by creating Service Account
;
var object =
googleDocumentFileId: "###", // Set the file ID of the existing Google Document
textData: "hi there",
;
const accessToken = await getAccessToken(serviceAccount);
if (accessToken)
object.accessToken = accessToken;
overWriting(object);



main();





share|improve this answer

























  • @bluejayke I understood that you want to overwrite Google Document with a text value without using googleapis. For this situation, I added a sample script. Could you please confirm it? If this was not what you want, I apologize.

    – Tanaike
    Apr 2 at 7:54











  • @bluejayke Did my additional sample script show you the result what you want? Would you please tell me about it? That is also useful for me to study. If you have issues for my answer yet, I apologize. At that time, can I ask you about your current situation? I would like to study to solve your issues.

    – Tanaike
    Apr 4 at 0:59











  • @bluejayke Is there anything that I can do for your question? If my answer was not useful for your situation. I have to apologize and modify it. If you can cooperate to resolve your issue, I'm glad. I would like to think of about the solution.

    – Tanaike
    Apr 6 at 1:58













0












0








0







  • You want to overwrite the existing Google Document by a text of hi there with Drive API using Service Account.

  • The Google Document is shared with the Service Account.

  • You can use googleapis.

I could understand like above. If my understanding is correct, how about this sample script? In this sample script, I used the files.update method of Drive API.



Sample script:



Before you run the script, please set the json file path downloaded when the Service Account is created. And please confirm the file ID of Google Document, again.



const stream = require('stream');
const google = require('googleapis');
const creds = require('###'); // Please set the json file path downloaded when the Service Account is created.
const jwtClient = new google.auth.JWT(
creds.client_email,
null,
creds.private_key,
['https://www.googleapis.com/auth/drive'],
null
);

const id = "1vebqOamZ9QB4HqfUaQN-U9Zt4y33eij-I21glMvaPVQ"; // Please set the file ID of Google Document
const content = "hi there"; // Please set the text.

const drive = google.drive(version: 'v3', auth: jwtClient);
const buf = new Buffer(content, 'binary');
const buffer = Uint8Array.from(buf);
var bufferStream = new stream.PassThrough();
bufferStream.end(buffer);
const media =
mimeType: 'application/vnd.google-apps.document',
body: bufferStream,
;
drive.files.update(
fileId: id,
media: media,
, (err, res) =>
if (err)
console.log(err);
return;

console.log(res.data);
);


Note:



  • When you run the script, the existing Google Document is overwritten. So please be careful this. I recommend to use a sample Document for testing.

  • If this script didn't work, please confirm the following points.

    1. Drive API is enabled at API console.

    2. The Service Account can be used.

    3. The Google Document is shared with the Service Account.

    4. The version of googleapis is the latest one.


Reference:



  • Files: update

Edit:



  • You don't want to use googleapis.

  • You want to overwrite Google Document with a text value without using googleapis.

From your comments, I understood like above. If my understanding is correct, how about this sample script? When you run this script, please confirm the following points.



  1. About the script,

    • Please set privateKey and clientEmail from JSON file of Service Account.

    • Please set the file ID of the existing Google Document you want to overwrite.


  2. Drive API is enabled at API console.

  3. The Service Account can be used.

  4. The Google Document is shared with the Service Account.

  5. The version of googleapis is the latest one.

Sample script:



const cryptor = require('crypto');
const request = require('request');

// Get access token using Service Account
function getAccessToken(serviceAccount)
const scopes = ["https://www.googleapis.com/auth/drive"];
const url = "https://www.googleapis.com/oauth2/v4/token";
const header =
alg: "RS256",
typ: "JWT",
;
const now = Math.floor(Date.now() / 1000);
const claim =
iss: serviceAccount.clientEmail,
scope: scopes.join(" "),
aud: url,
exp: (now + 3600).toString(),
iat: now.toString(),
;
const signature = Buffer.from(JSON.stringify(header)).toString('base64') + "." + Buffer.from(JSON.stringify(claim)).toString('base64');
var sign = cryptor.createSign('RSA-SHA256');
sign.update(signature);
const jwt = signature + "." + sign.sign(serviceAccount.privateKey, 'base64');
return new Promise(function(resolve, reject)
request(
method: "post",
url: url,
body: JSON.stringify(
assertion: jwt,
grant_type: "urn:ietf:params:oauth:grant-type:jwt-bearer",
),
, (err, res, body) =>
if (err)
console.log(err);
return;

const obj = JSON.parse(body);
resolve(obj.access_token);
);
);


// Overwrite file in Google Drive
function overWriting(object)
const metadata =
mimeType: "application/vnd.google-apps.document",
;
const url = "https://www.googleapis.com/upload/drive/v3/files/" + object.googleDocumentFileId + "?uploadType=multipart";
const boundary = "xxxxxxxxxxx";
var data = "--" + boundary + "rn";
data += "Content-Disposition: form-data; name="metadata"rn";
data += "Content-Type: application/json; charset=UTF-8rnrn";
data += JSON.stringify(metadata) + "rn";
data += "--" + boundary + "rn";
data += "Content-Disposition: form-data; name="file"; filename="sample.txt"rn";
data += "Content-Type: text/plain" + "rnrn";
const payload = Buffer.concat([
Buffer.from(data, "utf8"),
new Buffer(object.textData, 'binary'),
Buffer.from("rn--" + boundary + "--", "utf8"),
]);
const options =
method: 'patch',
url: url,
headers:
"Content-Type": "multipart/related; boundary=" + boundary,
'Authorization': 'Bearer ' + object.accessToken,
,
body: payload,
;
request(options, (error, response, body) =>
console.log(body);
);



async function main()
const serviceAccount =
privateKey: "###", // private_key of JSON file retrieved by creating Service Account
clientEmail: "###", // client_email of JSON file retrieved by creating Service Account
;
var object =
googleDocumentFileId: "###", // Set the file ID of the existing Google Document
textData: "hi there",
;
const accessToken = await getAccessToken(serviceAccount);
if (accessToken)
object.accessToken = accessToken;
overWriting(object);



main();





share|improve this answer















  • You want to overwrite the existing Google Document by a text of hi there with Drive API using Service Account.

  • The Google Document is shared with the Service Account.

  • You can use googleapis.

I could understand like above. If my understanding is correct, how about this sample script? In this sample script, I used the files.update method of Drive API.



Sample script:



Before you run the script, please set the json file path downloaded when the Service Account is created. And please confirm the file ID of Google Document, again.



const stream = require('stream');
const google = require('googleapis');
const creds = require('###'); // Please set the json file path downloaded when the Service Account is created.
const jwtClient = new google.auth.JWT(
creds.client_email,
null,
creds.private_key,
['https://www.googleapis.com/auth/drive'],
null
);

const id = "1vebqOamZ9QB4HqfUaQN-U9Zt4y33eij-I21glMvaPVQ"; // Please set the file ID of Google Document
const content = "hi there"; // Please set the text.

const drive = google.drive(version: 'v3', auth: jwtClient);
const buf = new Buffer(content, 'binary');
const buffer = Uint8Array.from(buf);
var bufferStream = new stream.PassThrough();
bufferStream.end(buffer);
const media =
mimeType: 'application/vnd.google-apps.document',
body: bufferStream,
;
drive.files.update(
fileId: id,
media: media,
, (err, res) =>
if (err)
console.log(err);
return;

console.log(res.data);
);


Note:



  • When you run the script, the existing Google Document is overwritten. So please be careful this. I recommend to use a sample Document for testing.

  • If this script didn't work, please confirm the following points.

    1. Drive API is enabled at API console.

    2. The Service Account can be used.

    3. The Google Document is shared with the Service Account.

    4. The version of googleapis is the latest one.


Reference:



  • Files: update

Edit:



  • You don't want to use googleapis.

  • You want to overwrite Google Document with a text value without using googleapis.

From your comments, I understood like above. If my understanding is correct, how about this sample script? When you run this script, please confirm the following points.



  1. About the script,

    • Please set privateKey and clientEmail from JSON file of Service Account.

    • Please set the file ID of the existing Google Document you want to overwrite.


  2. Drive API is enabled at API console.

  3. The Service Account can be used.

  4. The Google Document is shared with the Service Account.

  5. The version of googleapis is the latest one.

Sample script:



const cryptor = require('crypto');
const request = require('request');

// Get access token using Service Account
function getAccessToken(serviceAccount)
const scopes = ["https://www.googleapis.com/auth/drive"];
const url = "https://www.googleapis.com/oauth2/v4/token";
const header =
alg: "RS256",
typ: "JWT",
;
const now = Math.floor(Date.now() / 1000);
const claim =
iss: serviceAccount.clientEmail,
scope: scopes.join(" "),
aud: url,
exp: (now + 3600).toString(),
iat: now.toString(),
;
const signature = Buffer.from(JSON.stringify(header)).toString('base64') + "." + Buffer.from(JSON.stringify(claim)).toString('base64');
var sign = cryptor.createSign('RSA-SHA256');
sign.update(signature);
const jwt = signature + "." + sign.sign(serviceAccount.privateKey, 'base64');
return new Promise(function(resolve, reject)
request(
method: "post",
url: url,
body: JSON.stringify(
assertion: jwt,
grant_type: "urn:ietf:params:oauth:grant-type:jwt-bearer",
),
, (err, res, body) =>
if (err)
console.log(err);
return;

const obj = JSON.parse(body);
resolve(obj.access_token);
);
);


// Overwrite file in Google Drive
function overWriting(object)
const metadata =
mimeType: "application/vnd.google-apps.document",
;
const url = "https://www.googleapis.com/upload/drive/v3/files/" + object.googleDocumentFileId + "?uploadType=multipart";
const boundary = "xxxxxxxxxxx";
var data = "--" + boundary + "rn";
data += "Content-Disposition: form-data; name="metadata"rn";
data += "Content-Type: application/json; charset=UTF-8rnrn";
data += JSON.stringify(metadata) + "rn";
data += "--" + boundary + "rn";
data += "Content-Disposition: form-data; name="file"; filename="sample.txt"rn";
data += "Content-Type: text/plain" + "rnrn";
const payload = Buffer.concat([
Buffer.from(data, "utf8"),
new Buffer(object.textData, 'binary'),
Buffer.from("rn--" + boundary + "--", "utf8"),
]);
const options =
method: 'patch',
url: url,
headers:
"Content-Type": "multipart/related; boundary=" + boundary,
'Authorization': 'Bearer ' + object.accessToken,
,
body: payload,
;
request(options, (error, response, body) =>
console.log(body);
);



async function main()
const serviceAccount =
privateKey: "###", // private_key of JSON file retrieved by creating Service Account
clientEmail: "###", // client_email of JSON file retrieved by creating Service Account
;
var object =
googleDocumentFileId: "###", // Set the file ID of the existing Google Document
textData: "hi there",
;
const accessToken = await getAccessToken(serviceAccount);
if (accessToken)
object.accessToken = accessToken;
overWriting(object);



main();






share|improve this answer














share|improve this answer



share|improve this answer








edited Apr 2 at 7:54

























answered Mar 30 at 1:15









TanaikeTanaike

29k3 gold badges14 silver badges30 bronze badges




29k3 gold badges14 silver badges30 bronze badges












  • @bluejayke I understood that you want to overwrite Google Document with a text value without using googleapis. For this situation, I added a sample script. Could you please confirm it? If this was not what you want, I apologize.

    – Tanaike
    Apr 2 at 7:54











  • @bluejayke Did my additional sample script show you the result what you want? Would you please tell me about it? That is also useful for me to study. If you have issues for my answer yet, I apologize. At that time, can I ask you about your current situation? I would like to study to solve your issues.

    – Tanaike
    Apr 4 at 0:59











  • @bluejayke Is there anything that I can do for your question? If my answer was not useful for your situation. I have to apologize and modify it. If you can cooperate to resolve your issue, I'm glad. I would like to think of about the solution.

    – Tanaike
    Apr 6 at 1:58

















  • @bluejayke I understood that you want to overwrite Google Document with a text value without using googleapis. For this situation, I added a sample script. Could you please confirm it? If this was not what you want, I apologize.

    – Tanaike
    Apr 2 at 7:54











  • @bluejayke Did my additional sample script show you the result what you want? Would you please tell me about it? That is also useful for me to study. If you have issues for my answer yet, I apologize. At that time, can I ask you about your current situation? I would like to study to solve your issues.

    – Tanaike
    Apr 4 at 0:59











  • @bluejayke Is there anything that I can do for your question? If my answer was not useful for your situation. I have to apologize and modify it. If you can cooperate to resolve your issue, I'm glad. I would like to think of about the solution.

    – Tanaike
    Apr 6 at 1:58
















@bluejayke I understood that you want to overwrite Google Document with a text value without using googleapis. For this situation, I added a sample script. Could you please confirm it? If this was not what you want, I apologize.

– Tanaike
Apr 2 at 7:54





@bluejayke I understood that you want to overwrite Google Document with a text value without using googleapis. For this situation, I added a sample script. Could you please confirm it? If this was not what you want, I apologize.

– Tanaike
Apr 2 at 7:54













@bluejayke Did my additional sample script show you the result what you want? Would you please tell me about it? That is also useful for me to study. If you have issues for my answer yet, I apologize. At that time, can I ask you about your current situation? I would like to study to solve your issues.

– Tanaike
Apr 4 at 0:59





@bluejayke Did my additional sample script show you the result what you want? Would you please tell me about it? That is also useful for me to study. If you have issues for my answer yet, I apologize. At that time, can I ask you about your current situation? I would like to study to solve your issues.

– Tanaike
Apr 4 at 0:59













@bluejayke Is there anything that I can do for your question? If my answer was not useful for your situation. I have to apologize and modify it. If you can cooperate to resolve your issue, I'm glad. I would like to think of about the solution.

– Tanaike
Apr 6 at 1:58





@bluejayke Is there anything that I can do for your question? If my answer was not useful for your situation. I have to apologize and modify it. If you can cooperate to resolve your issue, I'm glad. I would like to think of about the solution.

– Tanaike
Apr 6 at 1:58



















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55335703%2fnodejs-google-drive-api-how-to-update-file%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript