फ़ाइल से लेबल हटाना

इस पेज पर Google Drive की किसी फ़ाइल से लेबल हटाने का तरीका बताया गया है.

किसी फ़ाइल से फ़ाइल लेबल का मेटाडेटा हटाने के लिए, files.modifyLabels तरीका. कॉन्टेंट बनाने अनुरोध का मुख्य हिस्सा इसमें ModifyLabelsRequest . अनुरोध में कई चीज़ें शामिल हो सकती हैं जो अपने-आप लागू होते हैं. इसका मतलब है कि अगर कोई बदलाव मान्य है, तो पूरा अपडेट असफल होता है और इनमें से कोई भी नहीं डिपेंडेंट) के हिसाब से बदलाव लागू होते हैं.

ModifyLabelsRequest में LabelModification जो किसी फ़ाइल पर मौजूद लेबल में किया गया बदलाव है. इसमें एक उदाहरण भी शामिल हो सकता है में से FieldModification जो किसी लेबल फ़ील्ड में बदलाव है. फ़ाइल से लेबल हटाने के लिए, FieldModification.removeLabel को True पर सेट करें.

सफल होने पर, जवाब बॉडी में शामिल है जोड़े या अपडेट किए गए लेबल. ये डाइमेंशन Label टाइप का modifiedLabels ऑब्जेक्ट.

उदाहरण

नीचे दिया गया कोड सैंपल, सभी फ़ील्ड हटाने के लिए labelId का इस्तेमाल करने का तरीका बताता है fileId का इस्तेमाल करके लेबल से जोड़ा गया हो. उदाहरण के लिए, अगर किसी लेबल में टेक्स्ट और उपयोगकर्ता फ़ील्ड, दोनों को हटाने पर, टेक्स्ट और उपयोगकर्ता, दोनों दोनों मिट जाएंगे लेबल से संबंधित फ़ील्ड. वहीं, टेक्स्ट फ़ील्ड को अनसेट करने से यह हट जाती है लेबल से हटाया जाता है, लेकिन उपयोगकर्ता फ़ील्ड में कोई बदलाव नहीं किया जाता. ज़्यादा जानकारी के लिए, यह देखें फ़ाइल पर लेबल फ़ील्ड को अनसेट करें.

Java

ModifyLabelsRequest modifyLabelsRequest =
  new ModifyLabelsRequest()
      .setLabelModifications(
          ImmutableList.of(
              new LabelModification()
                .setLabelId("LABEL_ID")
                .setRemoveLabel(true)));

ModifyLabelsResponse modifyLabelsResponse = driveService.files().modifyLabels("FILE_ID", modifyLabelsRequest).execute();

Python

label_modification = {'labelId':'LABEL_ID', 'removeLabel': True]}

modified_labels = drive_service.files().modifyLabels(fileId="FILE_ID", body = {'labelModifications' : [label_modification]}).execute();

Node.js

/**
* Remove a label on a Drive file
* @return{obj} updated label data
**/
async function removeLabel() {
  // 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});
  const labelModification = {
    'labelId': 'LABEL_ID',
    'removeLabel': True,
  };
  const labelModificationRequest = {
    'labelModifications': [labelModification],
  };
  try {
    const updateResponse = await service.files.modifyLabels({
      fileId: 'FILE_ID',
      resource: labelModificationRequest,
    });
    return updateResponse;
  } catch (err) {
    // TODO (developer) - Handle error
    throw err;
  }

इन्हें बदलें:

  • LABEL_ID: बदलाव किए जाने वाले लेबल का labelId. पता लगाने के लिए लेबल लगाने के लिए, files.listLabels तरीका.
  • FILE_ID: उस फ़ाइल का fileId जिसके लिए लेबल हैं संशोधित.