विविध
संग्रह की मदद से व्यवस्थित रहें अपनी प्राथमिकताओं के आधार पर, कॉन्टेंट को सेव करें और कैटगरी में बांटें.
फ़ाइल डाउनलोड और अपलोड करें
function sendHttpPost() {
// Download a file now (GET), so we can upload it in the HTTP POST below.
const response = UrlFetchApp.fetch('https://www.google.com/favicon.ico');
const fileBlob = response.getBlob();
const payload = {
'fieldOne' : 'value for field one',
'fieldTwo' : 'value for field two',
'fileAttachment': fileBlob
};
// Because payload is a JavaScript object, it will be interpreted as
// an HTML form. (We do not need to specify contentType; it will
// automatically default to either 'application/x-www-form-urlencoded'
// or 'multipart/form-data')
const options = {
'method' : 'post',
'payload' : payload
};
UrlFetchApp.fetch('http://example.com/upload_form.cgi', options);
}
फ़ाइल को ज़िप और अनज़िप करें
function zipUnzip() {
const googleFavIconUrl = 'https://www.google.com/favicon.ico';
const googleLogoUrl = 'https://www.google.com/images/srpr/logo3w.png';
// Fetch the Google favicon.ico file and get the Blob data.
const faviconBlob = UrlFetchApp.fetch(googleFavIconUrl).getBlob();
const logoBlob = UrlFetchApp.fetch(googleLogoUrl).getBlob();
// zip now references a blob containing an archive of both faviconBlob and
// logoBlob.
const zip = Utilities.zip([faviconBlob, logoBlob], 'google_images.zip');
// This will now unzip the blobs.
const files = Utilities.unzip(zip);
}
csv फ़ाइल पार्स करें
function parseCsv() {
// This will create a 2 dimensional array of the format
// [[a, b, c], [d, e, f]]
const csvString = 'a,b,c\nd,e,f';
const data = Utilities.parseCsv(csvString);
console.log(data);
}
function formatString() {
// You can use sprintf-like string formatting using '%'-style format
// strings.
// will be: '123.456000'
Utilities.formatString('%11.6f', 123.456);
// will be: ' abc'
Utilities.formatString('%6s', 'abc');
}
बेस64 एन्कोड करें और स्ट्रिंग डीकोड करें
function base64Encoding() {
// base64 encoding is used to encode binary data to a text format
// you may need to do this if your transfer method can't handle spaces,
// non-English characters, etc.
// We'll instantiate a blob here for clarity.
const blob = Utilities.newBlob('A string here');
// Let's return the blob data as a byte[].
const encoded = Utilities.base64Encode(blob.getBytes());
// This will log 'QSBzdHJpbmcgaGVyZQ=='
console.log(encoded);
const decoded = Utilities.base64Decode(encoded);
// This will log the original string.
console.log(Utilities.newBlob(decoded).getDataAsString());
}
खाते के समय क्षेत्र में तारीख के साथ एक स्ट्रिंग पाएं
function getDateStringInTimeZone() {
// Default to the current date and time. For a particular date, pass a
// date string to new Date() such as
// "February 17, 2016 13:00:00 -0500". Always include a timezone
// specifier in the date string, or the date string may be interpreted
// using a different timezone than you intend.
const date = new Date();
// Default to the account timezone. To customize, see
// https://developers.google.com/google-ads/api/reference/data/codes-formats#timezone-ids
// e.g. const timezone = "Europe/Berlin"
const timeZone = AdsApp.currentAccount().getTimeZone();
// For other formats, see
// https://developers.google.com/apps-script/reference/utilities/utilities#formatdatedate-timezone-format
// If constructing a new date from the returned date string, be sure the
// format includes the time zone letter 'Z', or the date string may be
// interpreted using a different timezone than you intend.
const format = 'MMM dd, yyyy HH:mm:ss Z';
return Utilities.formatDate(date, timeZone, format);
}
विगत तारीख पाएं
function getDateInThePast() {
// Number of milliseconds in a day.
const MILLIS_PER_DAY = 1000 * 60 * 60 * 24;
// Default to the current date and time. For a particular date, pass a
// date string to new Date() such as
// "February 17, 2016 13:00:00 -0500". Always include a timezone
// specifier in the date string, or the date string may be interpreted
// using a different timezone than you intend.
const date = new Date();
// Number of days in the past.
const numDays = 3;
return new Date(date.getTime() - numDays * MILLIS_PER_DAY);
}
जब तक कुछ अलग से न बताया जाए, तब तक इस पेज की सामग्री को Creative Commons Attribution 4.0 License के तहत और कोड के नमूनों को Apache 2.0 License के तहत लाइसेंस मिला है. ज़्यादा जानकारी के लिए, Google Developers साइट नीतियां देखें. Oracle और/या इससे जुड़ी हुई कंपनियों का, Java एक रजिस्टर किया हुआ ट्रेडमार्क है.
आखिरी बार 2025-05-01 (UTC) को अपडेट किया गया.
[[["समझने में आसान है","easyToUnderstand","thumb-up"],["मेरी समस्या हल हो गई","solvedMyProblem","thumb-up"],["अन्य","otherUp","thumb-up"]],[["वह जानकारी मौजूद नहीं है जो मुझे चाहिए","missingTheInformationINeed","thumb-down"],["बहुत मुश्किल है / बहुत सारे चरण हैं","tooComplicatedTooManySteps","thumb-down"],["पुराना","outOfDate","thumb-down"],["अनुवाद से जुड़ी समस्या","translationIssue","thumb-down"],["सैंपल / कोड से जुड़ी समस्या","samplesCodeIssue","thumb-down"],["अन्य","otherDown","thumb-down"]],["आखिरी बार 2025-05-01 (UTC) को अपडेट किया गया."],[[["Utilize the `UrlFetchApp` class to download and upload files, including handling file attachments in HTTP POST requests."],["Employ the `Utilities` class to zip and unzip files, enabling efficient management of multiple files within scripts."],["Parse CSV data into a 2-dimensional array using the `Utilities.parseCsv()` function, simplifying data extraction from CSV strings."],["Format strings using the `Utilities.formatString()` function, providing control over string representation with format specifiers."],["Encode and decode data in base64 format with the `Utilities.base64Encode()` and `Utilities.base64Decode()` functions, enabling secure data handling within scripts."],["Get the current date and time in the user's account timezone and format it according to specified format using the `Utilities.formatDate()` method."],["Calculate and retrieve a date in the past by manipulating the current date and time using milliseconds."]]],[]]