---
sourceDocument: Xanadu API 참조
sourceDocumentLink: https://servicenow-prod.fluidtopics.net/r/ko-KR/xanadu/api-reference

 Release :

    - xanadu

ft:locale :

    - ko-KR

ft:publication_title :

    - Xanadu API 참조

ft:clusterId :

    - crapiref

bundleId :

    - crapiref

workflow :

    - Creator


---

# GlideSysAttachment - 전역

# GlideSysAttachment - 전역 {#ariaid-title1}

* 릴리스 버전: Xanadu
* 
* 업데이트 날짜 2024년 08월 01일
* 
* ![](https://www.servicenow.com/docs/portal-asset/ico-clock) 소요 시간: 8분

GlideSysAttachment API는 첨부 파일을 처리하기 위한 메서드를 제공합니다.

Content는 getContent() 가 호출될 때 바이트 배열이 아닌 문자열로 반환됩니다.

컨텐츠는 getContentStream()이 호출될 때 GlideScriptableInputStream 객체로 반환됩니다. GlideScriptableInputStream에는 문자열로 변환되지 않은 실제 바이트가 포함되어 있습니다.

## GlideSysAttachment - GlideSysAttachment() {#ariaid-title2}

GlideSysAttachment 클래스의 인스턴스를 작성합니다.
{#GSA-GlideSysAttachment__table_iys_ctb_fv__entry__3}

| 이름 | 유형 | 설명 |
|-|-|-|
| 없음 |   |   |
[표 1. 매개변수]

{#GSA-GlideSysAttachment__table_iys_ctb_fv}

## GlideSysAttachment - 복사(문자열 sourceTable, 문자열 sourceID, 문자열 targetTable, 문자열 targetID) {#ariaid-title3}

원본 기록에서 대상 기록으로 첨부 파일을 복사합니다.
{#GSA-copy_S_S_S_S__id_g4d_yjz_g5b__entry__3}

| 이름 | 유형 | 설명 |
|-|-|-|
| sourceTable | 문자열 | 복사할 첨부 파일이 있는 테이블의 이름입니다. |
| 소스 ID | 문자열 | 소스 테이블의 sys_id입니다. |
| targetTable | 문자열 | 첨부 파일을 추가할 테이블의 이름입니다. |
| targetID | 문자열 | 대상 테이블의 sys_id입니다. |
[표 2. 매개변수]

{#GSA-copy_S_S_S_S__id_g4d_yjz_g5b} {#GSA-copy_S_S_S_S__id_afm_yjz_g5b__entry__2}

| 유형 | 설명 |
|-|-|
| 문자열 | 복사된 첨부 파일의 sys_ids 배열입니다. |
[표 3. 반환]

{#GSA-copy_S_S_S_S__id_afm_yjz_g5b}  

    var attachment = new GlideSysAttachment();
    var incidentSysID = 'ab1b30031b04ec101363ff37dc4bcbfc';
    var incGR = new GlideRecord('incident');
    incGR.get(incidentSysID);

    var copiedAttachments = attachment.copy('incident', incidentSysID, 'problem', incGR.getValue('problem_id'));
    gs.info('Copied attachments: ' + copiedAttachments);

출력:

    Copied attachments: 6e4621df1bc420501363ff37dc4bcbb0,a87769531b0820501363ff37dc4bcba2

## GlideSysAttachment - deleteAttachment(문자열 attachmentID) {#ariaid-title4}

지정된 첨부 파일을 삭제합니다.
{#GSA-deleteAttachment_S__id_ywb_ykz_g5b__entry__3}

| 이름 | 유형 | 설명 |
|-|-|-|
| 첨부 파일 ID | 문자열 | 첨부 파일의 sys_id입니다. |
[표 4. 매개변수]

{#GSA-deleteAttachment_S__id_ywb_ykz_g5b} {#GSA-deleteAttachment_S__table_gjy_lyb_fv__entry__2}

| 유형 | 설명 |
|-|-|
| void |   |
[표 5. 반환]

{#GSA-deleteAttachment_S__table_gjy_lyb_fv}  

    var attachment = new GlideSysAttachment();
    var attachmentSysID = 'a87769531b0820501363ff37dc4bcba2';
    attachment.deleteAttachment(attachmentSysID);

## GlideSysAttachment - getAttachments(문자열 tableName, 문자열 sys_id) {#ariaid-title5}

이름, 유형 또는 크기와 같은 일치하는 첨부 파일 메타데이터가 포함된 GlideRecord를 반환합니다.
{#GSA-getAttachments_S_S__id_m5v_14z_g5b__entry__3}

| 이름 | 유형 | 설명 |
|-|-|-|
| tableName | 문자열 | 첨부 파일이 속한 테이블의 이름입니다. 예: 인시던트. |
| sys_id | 문자열 | 첨부 파일이 속한 기록의 Sys_id입니다. |
[표 6. 매개변수]

{#GSA-getAttachments_S_S__id_m5v_14z_g5b} {#GSA-getAttachments_S_S__id_qr3_c4z_g5b__entry__2}

| 유형 | 설명 |
|-|-|
| GlideRecord | 이름, 유형 또는 크기와 같은 일치하는 첨부 파일 메타데이터를 포함하는 GlideRecord 객체입니다. |
[표 7. 반환]

{#GSA-getAttachments_S_S__id_qr3_c4z_g5b}  
다음 스크립트는 두 개의 첨부 파일이 있는 기록의 첨부 파일 이름을 나열합니다.

    var attachment = new GlideSysAttachment();

    var agr = attachment.getAttachments('<table_name>', '<record_sys_id>');

    while(agr.next())
    gs.info(agr.getValue('file_name'));

출력:

    *** Script: filename1.txt
    *** Script: filename2.txt

## GlideSysAttachment - getContentStream(문자열 sysID) {#ariaid-title6}

첨부 파일 sys_id 지정된 GlideScriptableInputStream 객체를 반환합니다.
[GlideTextReader](https://servicenow-prod.fluidtopics.net/Bqtnrq94y9PpIqifVdpv8A#c_GlideTextReaderScopedAPI "GlideTextReader API는 입력 스트림에서 한 줄을 읽을 수 있는 기능을 제공합니다. 입력 스트림이 사용되기 때문에 5MB 첨부 파일 크기 제한이 적용되지 않습니다.") API를 사용하여 컨텐츠 스트림을 읽을 수 있습니다.
{#GSA-getContentStream_S__id_sdc_44z_g5b__entry__3}

| 이름 | 유형 | 설명 |
|-|-|-|
| sysID | 문자열 | 첨부 파일 sys_id. |
[표 8. 매개변수]

{#GSA-getContentStream_S__id_sdc_44z_g5b} {#GSA-getContentStream_S__id_nqx_44z_g5b__entry__2}

| 유형 | 설명 |
|-|-|
| GlideScriptableInputStream | 첨부 파일 컨텐츠가 포함된 스트림입니다. |
[표 9. 반환]

{#GSA-getContentStream_S__id_nqx_44z_g5b}  

    var attachment = new GlideSysAttachment();
    var attachmentSysID = '6e4621df1bc420501363ff37dc4bcbb0';
    var attachmentContentStream = attachment.getContentStream(attachmentSysID);
    gs.info('Attachment content stream: ' + attachmentContentStream);

출력:

    Attachment content stream: com.glide.communications.GlideScriptableInputStream@14bd299

## GlideSysAttachment - 쓰기(GlideRecord 기록, 문자열 fileName, 문자열 contentType, 문자열 콘텐츠) {#ariaid-title7}

지정된 첨부 파일을 지정된 기록에 첨부합니다.
{#GSA-write_GR_S_S_S__id_odn_1pz_g5b__entry__3}

| 이름 | 유형 | 설명 |
|-|-|-|
| 기록 | GlideRecord | 첨부 파일을 첨부할 기록입니다. |
| fileName | 문자열 | 첨부 파일 이름입니다. |
| 콘텐츠 유형 | 문자열 | 첨부 파일 컨텐츠 유형입니다. |
| 컨텐츠 | 문자열 | 첨부 파일 컨텐츠입니다. |
[표 10. 매개변수]

{#GSA-write_GR_S_S_S__id_odn_1pz_g5b} {#GSA-write_GR_S_S_S__id_kbx_1pz_g5b__entry__2}

| 유형 | 설명 |
|-|-|
| 문자열 | 첨부 파일 sys_id. 첨부 파일이 추가되지 않은 경우 null을 반환합니다. |
[표 11. 반환]

{#GSA-write_GR_S_S_S__id_kbx_1pz_g5b}  

    var attachment = new GlideSysAttachment();

    //set up inputs
    var rec = new GlideRecord('incident');
    rec.get('78271e1347c12200e0ef563dbb9a7109');
    var fileName = 'example.txt';
    var contentType = 'text/csv';
    var content = 'The text that is stored inside my file';

    var agr = attachment.write(rec, fileName, contentType, content);

    gs.info('The attachment sys_id is: ' + agr);

출력:

    The attachment sys_id is: 01271e4317c13311e0ef563dbb9abe34

## GlideSysAttachment - writeContentStream(GlideRecord now_GR, 문자열 파일 이름, 문자열 contentType, GlideScriptableInputStream inputStream) {#ariaid-title8}

입력 스트림을 사용하여 첨부 파일을 삽입합니다.
{#GSA-writeContentStrm_GR_S_S_GSIS__id_trk_jpz_g5b__entry__3}

| 이름 | 유형 | 설명 |
|-|-|-|
| now_GR | GlideRecord | 첨부 파일을 첨부할 기록입니다. |
| fileName | 문자열 | 첨부 파일의 이름입니다. |
| 콘텐츠 유형 | 문자열 | 첨부 파일의 컨텐츠 유형입니다. |
| 컨텐츠 | GlideScriptableInputStream | 첨부 파일 컨텐츠입니다. |
[표 12. 매개변수]

{#GSA-writeContentStrm_GR_S_S_GSIS__id_trk_jpz_g5b} {#GSA-writeContentStrm_GR_S_S_GSIS__id_ncv_jpz_g5b__entry__2}

| 유형 | 설명 |
|-|-|
| 문자열 | 작성된 첨부 파일의 Sys_id입니다. |
[표 13. 반환]

{#GSA-writeContentStrm_GR_S_S_GSIS__id_ncv_jpz_g5b}  
sys_attachment 테이블의 컨텐츠 스트림을 test_table 기록에 첨부합니다.

    function copyAttachmentToGlideRecord(conceptSysId) {

      // Get record from test_table using sys_id
      var targetGlideRecord = new GlideRecord("test_table");
      if (!targetGlideRecord.get(conceptSysId)) {
         throw ("Cannot find record created by test with sys_id: " + conceptSysId);
      }

      // Get record from sys_attachment table
      var sourceAttachmentGlideRecord = new GlideRecord('sys_attachment');    
      sourceAttachmentGlideRecord.query();
      sourceAttachmentGlideRecord.next();

      // Get field values from retrieved sys_attachment record
      var fileName = sourceAttachmentGlideRecord.getValue('file_name');
      var contentType = sourceAttachmentGlideRecord.getValue('content_type');
      var sourceAttachmentSysId = sourceAttachmentGlideRecord.getValue('sys_id');

      // Attach sys_attachment record content stream to test_table record
      var gsa = new GlideSysAttachment();
      gsa.writeContentStream(
        targetGlideRecord,
        fileName,
        contentType,
        gsa.getContentStream(sourceAttachmentSysId));
      gs.info("Attachment created");
    }


