파일의 라벨 필드 설정 해제

이 페이지에서는 라벨을 설정 해제하는 방법을 설명합니다. 단일 기준의 Field Google Drive 파일

파일 라벨을 설정 해제하여 파일에서 메타데이터를 삭제하려면 files.modifyLabels 메서드를 사용하여 지도 가장자리에 패딩을 추가할 수 있습니다. 이 요청 본문 다음 인스턴스를 포함합니다. ModifyLabelsRequest 파일의 라벨 집합을 수정할 수 있습니다. 요청에는 여러 개의 여러 개의 메서드를 제공합니다. 즉, 수정이 이뤄지지 않은 전체 업데이트가 실패하고 변경사항이 적용됩니다.

ModifyLabelsRequest에는 LabelModification 이는 파일의 라벨에 대한 수정입니다. 또한 Compute Engine / FieldModification 라벨 필드를 수정한 것입니다. 필드 값을 설정 해제하려면 다음 안내를 따르세요. FieldModification.unsetValuesTrue로 설정합니다.

성공하면 응답은 body 포함 요청에 의해 추가되거나 업데이트된 라벨입니다. 이러한 디바이스는 Label 유형의 modifiedLabels 객체

다음 코드 샘플은 fieldIdlabelId를 사용하여 설정을 해제하는 방법을 보여줍니다. 연결된 fileId의 필드 값입니다. 예를 들어 라벨에 텍스트 필드와 사용자 필드를 모두 설정 해제하여 라벨에서 삭제합니다. 사용자 필드는 변경되지 않습니다. 반면 라벨을 삭제하면 라벨을 지정합니다. 자세한 내용은 파일에서 라벨 삭제

자바

LabelFieldModification fieldModification =
  new LabelFieldModification().setFieldId("FIELD_ID").setUnsetValues(true);

ModifyLabelsRequest modifyLabelsRequest =
  new ModifyLabelsRequest()
      .setLabelModifications(
          ImmutableList.of(
              new LabelModification()
                .setLabelId("LABEL_ID")
                .setFieldModifications(ImmutableList.of(fieldModification))));

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

Python

field_modification = {'fieldId':'FIELD_ID','unsetValues':True}
label_modification = {'labelId':'LABEL_ID', 'fieldModifications':[field_modification]}

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

Node.js

/**
* Unset a label with a field on a Drive file
* @return{obj} updated label data
**/
async function unsetLabelField() {
  // 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 fieldModification = {
    'fieldId': 'FIELD_ID',
    'unsetValues': True,
  };
  const labelModification = {
    'labelId': 'LABEL_ID',
    'fieldModifications': [fieldModification],
  };
  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;
  }
}

다음을 바꿉니다.

  • FIELD_ID: 수정할 필드의 fieldId입니다. 위치 확인 fieldIdGoogle Drive Labels API.
  • LABEL_ID: 수정할 라벨의 labelId입니다.
  • FILE_ID: 라벨이 있는 파일의 fileId 수정됨