इस पेज पर, Google Drive फ़ाइल रिसॉर्स से कुछ खास लेबल वापस पाने का तरीका बताया गया है.
आपको कौनसे लेबल वापस पाने हैं, यह तय करने के लिए files.get तरीके का इस्तेमाल करें. इसके अलावा, फ़ाइल रिसॉर्स वापस लाने वाले किसी भी तरीके का इस्तेमाल किया जा सकता है. अनुरोध का मुख्य हिस्सा खाली होना चाहिए.
अगर अनुरोध पूरा हो जाता है, तो जवाब के मुख्य हिस्से में File का एक इंस्टेंस शामिल होता है.
उदाहरण
यहां दिए गए कोड सैंपल में, fileId और labelId का इस्तेमाल करके, लेबल का सेट वापस पाने का तरीका बताया गया है. includeLabels ऑब्जेक्ट, कॉमा लगाकर अलग किए गए आईडी की सूची होती है. fields पैरामीटर में मौजूद labelInfo ऑब्जेक्ट में, फ़ाइल पर सेट किए गए लेबल और includeLabels में अनुरोध किए गए लेबल शामिल होते हैं.
Java
File file = driveService.files().get("FILE_ID").setIncludeLabels("LABEL_ID,LABEL_ID").setFields("labelInfo").execute();
Python
file = drive_service.files().get(fileId="FILE_ID", includeLabels="LABEL_ID,LABEL_ID", fields="labelInfo").execute();
Node.js
/**
* Get a Drive file with specific labels
* @return{obj} file with labelInfo
**/
async function getFileWithSpecificLabels() {
// Get credentials and build service
// TODO (developer) - Use appropriate auth mechanism for your app
const {GoogleAuth} = require('google-auth-library');
const {google} = require('googleapis');
const auth = new GoogleAuth({scopes: 'https://www.googleapis.com/auth/drive'});
const service = google.drive({version: 'v3', auth});
try {
const file = await service.files.get({
fileId: 'FILE_ID',
includeLabels: 'LABEL_ID,LABEL_ID',
fields:'labelInfo',
});
return file;
} catch (err) {
// TODO (developer) - Handle error
throw err;
}
}
इनकी जगह ये डालें:
- FILE_ID: लेबल वाली फ़ाइल का
fileId. - LABEL_ID: लौटाए जाने वाले प्रॉडक्ट के लेबल का
labelId. किसी फ़ाइल पर मौजूद लेबल ढूंढने के लिए,files.listLabelsतरीके का इस्तेमाल करें.
नोट
- फ़ाइल
संसाधन को वापस लाने वाला कोई भी तरीका,
includeLabelsफ़ील्ड और क्वेरी पैरामीटर के साथ काम करता है. उदाहरण के लिए,files.copy,files.list, औरfiles.update.