/** * List labels available to the user. */functionlistLabels(){letpageToken=null;letlabels=[];do{try{constresponse=DriveLabels.Labels.list({publishedOnly:true,pageToken:pageToken});pageToken=response.nextPageToken;labels=labels.concat(response.labels);}catch(err){// TODO (developer) - Handle exceptionconsole.log('Failed to list labels with error %s',err.message);}}while(pageToken!=null);console.log('Found %d labels',labels.length);}
라벨 가져오기
다음 코드 샘플은 리소스 이름(라벨의 문자열 값)으로 단일 라벨을 가져오는 방법을 보여줍니다. 라벨 이름을 찾으려면 API를 통해 라벨 목록을 가져오거나 Drive 라벨 관리자를 사용하세요. 라벨 관리자에 대한 자세한 내용은 Drive 라벨 관리하기를 참고하세요.
/** * Get a label by name. * @param {string} labelName The label name. */functiongetLabel(labelName){try{constlabel=DriveLabels.Labels.get(labelName,{view:'LABEL_VIEW_FULL'});consttitle=label.properties.title;constfieldsLength=label.fields.length;console.log(`Fetched label with title: '${title}' and ${fieldsLength} fields.`);}catch(err){// TODO (developer) - Handle exceptionconsole.log('Failed to get label with error %s',err.message);}}
Drive 항목의 라벨 나열
다음 코드 샘플은 Drive 항목을 가져오고 해당 항목에 적용된 모든 라벨을 나열하는 방법을 보여줍니다.
/** * List Labels on a Drive Item * Fetches a Drive Item and prints all applied values along with their to their * human-readable names. * * @param {string} fileId The Drive File ID */functionlistLabelsOnDriveItem(fileId){try{constappliedLabels=Drive.Files.listLabels(fileId);console.log('%d label(s) are applied to this file',appliedLabels.labels.length);appliedLabels.labels.forEach((appliedLabel)=>{// Resource name of the label at the applied revision.constlabelName='labels/'+appliedLabel.id+'@'+appliedLabel.revisionId;console.log('Fetching Label: %s',labelName);constlabel=DriveLabels.Labels.get(labelName,{view:'LABEL_VIEW_FULL'});console.log('Label Title: %s',label.properties.title);Object.keys(appliedLabel.fields).forEach((fieldId)=>{constfieldValue=appliedLabel.fields[fieldId];constfield=label.fields.find((f)=>f.id==fieldId);console.log(`Field ID: ${field.id}, Display Name: ${field.properties.displayName}`);switch(fieldValue.valueType){case'text':console.log('Text: %s',fieldValue.text[0]);break;case'integer':console.log('Integer: %d',fieldValue.integer[0]);break;case'dateString':console.log('Date: %s',fieldValue.dateString[0]);break;case'user':constuser=fieldValue.user.map((user)=>{return`${user.emailAddress}: ${user.displayName}`;}).join(', ');console.log(`User: ${user}`);break;case'selection':constchoices=fieldValue.selection.map((choiceId)=>{returnfield.selectionOptions.choices.find((choice)=>choice.id===choiceId);});constselection=choices.map((choice)=>{return`${choice.id}: ${choice.properties.displayName}`;}).join(', ');console.log(`Selection: ${selection}`);break;default:console.log('Unknown: %s',fieldValue.valueType);console.log(fieldValue.value);}});});}catch(err){// TODO (developer) - Handle exceptionconsole.log('Failed with error %s',err.message);}}
[[["이해하기 쉬움","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-08-31(UTC)"],[],[]]