파일에서 라벨 삭제하기

이 페이지에서는 단일 Google Drive 파일에서 라벨을 삭제하는 방법을 설명합니다.

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

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

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

다음 코드 샘플은 labelId를 사용하여 모든 필드를 삭제하는 방법을 보여줍니다. fileId를 사용하여 라벨과 연결됩니다. 예를 들어 라벨에 텍스트 및 사용자 필드 모두 삭제. 라벨을 삭제하면 텍스트와 사용자 모두 삭제됩니다. 입력란입니다. 반면 텍스트 입력란을 설정 해제하면 사용자 필드는 그대로 둡니다. 자세한 내용은 파일의 라벨 필드 설정 해제

자바

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 수정됨