> ## Documentation Index
> Fetch the complete documentation index at: https://www.integrate.io/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# ETL: Google 드라이브에서 파일 연동

> Integrate.io ETL에서 Google Drive 커넥션을 만들고 텍스트, CSV, TSV 형식의 파일을 읽어 데이터베이스나 파일 스토리지 등 다른 시스템으로 연동하는 절차와 활용 팁을 자세히 안내합니다. 운영 시 참고할 수 있도록 단계별로 정리했습니다.

**소개**

Google 드라이브는 Google에서 제공하는 무료 온라인 저장소(스토리지)입니다. 문서 파일, 사진, 음악, 동영상 등 다양한 형태의 데이터를 인터넷을 통해 저장할 수 있는 매우 편리한 서비스입니다.
이번에는 Xplenty에 의한 Google 드라이브의 텍스트나 CSV/TSV 형식의 파일을 읽고 다른 시스템에 연계하는 방법을 소개합니다. 주요한 연계 시스템은 Destination의 파일 스토리지나 데이터베이스가 되겠습니다.

보다 편리하게 사용하기 위한 간단한 활용법도 소개합니다.
**파일 연합 준비 사항**

Google 드라이브에서 파일을 연결하려면 준비가 필요합니다.

우선, Google 드라이브 커넥션의 작성과 그 커넥션의 Unique ID나 대상의 Google 드라이브의 드라이브 ID를 아래의 그림을 참고해 확인해 주세요.
지정한 파일을 Google 드라이브에서 가져오기 위한 쿼리 문자열을 구글 페이지를 참고하여 만들고, URL Encode를 통한 변환도 미리 해 두십시요.

* 연결 페이지에서 복사 소스 인 Google 드라이브의 연결을 생성하고 커넥션의 Unique ID를 얻습니다.
  \[

<Frame>
  <img src="https://mintcdn.com/integrateio/8_YWxtQNutL7liVJ/images/creating-packages/restapi-part08-ko/image-1.webp?fit=max&auto=format&n=8_YWxtQNutL7liVJ&q=85&s=c99e0e2d6998ae2df53b7dd0aeda03dc" alt="restapi-part08-ko image 1" width="1138" height="878" data-path="images/creating-packages/restapi-part08-ko/image-1.webp" />
</Frame>

]\([https://cdn.filestackcontent.com/auto\_image//compress/cache=expiry:max/7Hp99JlSTImD6XpMWNTQ](https://cdn.filestackcontent.com/auto_image//compress/cache=expiry:max/7Hp99JlSTImD6XpMWNTQ))

* URL로부터 대상 드라이브의 ID와 대상 파일명을 취득(아래 그림의 ①과 ②에 해당)
  \[

<Frame>
  <img src="https://mintcdn.com/integrateio/8_YWxtQNutL7liVJ/images/creating-packages/restapi-part08-ko/image-2.webp?fit=max&auto=format&n=8_YWxtQNutL7liVJ&q=85&s=fb2530d1cb7b25829912ac211ea3ae52" alt="restapi-part08-ko image 2" width="1200" height="606" data-path="images/creating-packages/restapi-part08-ko/image-2.webp" />
</Frame>

]\([https://cdn.filestackcontent.com/auto\_image//compress/cache=expiry:max/FenN0S7eRVeohn7yYrLs](https://cdn.filestackcontent.com/auto_image//compress/cache=expiry:max/FenN0S7eRVeohn7yYrLs))

* Google Drive의 가이드에 있는 \< [쿼리 문자열의 예](https://developers.google.com/drive/api/guides/search-files?hl=ja#examples) >를 참고하여 Google API와 대상 파일명이 취득한 쿼리 문자열을 합체하여 URL을 URL Encoder로 변환해 (아래 예시 참조)

## 쿼리 문자열의 예

지정된 구글 드라이브에서 파일이름이 head\_content를 포함하고 mineTYpe이 CSV형식인 파일 리스트의 받기

\<Google API의 URL>
[https://www.googleapis.com/drive/v3/files?q=\&lt;쿼리\_문자열>](https://www.googleapis.com/drive/v3/files?q=\&lt;쿼리_문자열>)

\<쿼리 문자열>
name contains "head\_content" and mimeType="text/csv" and "\<---구글\_드라이브\_ID--->" in parents

\<URL Encode로 변혼한 파일 리스트 취득 URL>
[https://www.googleapis.com/drive/v3/files?q=name+contains+%22head\_content%22+and+mimeType%3D%22text%2Fcsv%22+and+%22\&lt;---구글\_드라이브\_ID--->%22+in+parents](https://www.googleapis.com/drive/v3/files?q=name+contains+%22head_content%22+and+mimeType%3D%22text%2Fcsv%22+and+%22\&lt;---구글_드라이브_ID--->%22+in+parents)

그럼, 여기로부터 Xplenty를 사용한 파일 연계의 본격적인 순서입니다. 아래의 순서대로 설정하면 Google 드라이브를 통한 파일 연계가 가능해 집니다.
**파일 연계 절차**

이 섹션에서는 Google 드라이브에서 텍스트 형식의 파일 (TXT, CSV, TSV)을 파일 스토리지 및 데이터베이스에 연결하는 단계에 대해 설명합니다.
먼저 Xplenty에서 익숙한 Package 작성/편집 화면에서 **+Add Component**를 클릭하고 Source에서 REST API 아이콘을 선택합니다. RestAPI 컴포넌트를 열고 아래 그림과 같이 상세 내용을 설정하여 해당 파일이 선택되어 있는지 확인하십시오.

*

RestAPI 컴포넌트에서 Google API를 사용하여 파일 목록 가져오기인증 유형은 연결을 선택하고 Google 드라이브 연결을 지정합니다. Method and URL 설정은 다음과 같습니다.
\[

<Frame>
  <img src="https://mintcdn.com/integrateio/8_YWxtQNutL7liVJ/images/creating-packages/restapi-part08-ko/image-3.webp?fit=max&auto=format&n=8_YWxtQNutL7liVJ&q=85&s=c89e1d4319ea998aed698f914abaf3b3" alt="restapi-part08-ko image 3" width="1200" height="613" data-path="images/creating-packages/restapi-part08-ko/image-3.webp" />
</Frame>

]\([https://cdn.filestackcontent.com/auto\_image//compress/cache=expiry:max/Na0F5cGKQI6Inkadn43Q](https://cdn.filestackcontent.com/auto_image//compress/cache=expiry:max/Na0F5cGKQI6Inkadn43Q))

* Method - **GET**으로 설정

* URL - `https://www.googleapis.com/drive/v3/files?q=name+contains+%22head_content%22+and+mimeType%3D%22text%2Fcsv%22+and+%22&lt;---구글_드라이브_ID--->%22+in+parents`

* Response - **JSON** 선택 및 `$.files[*]`을 설정

Google API URL과 파일 선택 쿼리 문자열로 만든 URL을 설정하고 Response는 JSON형식으로 받습니다.

\[

<Frame>
  <img src="https://mintcdn.com/integrateio/8_YWxtQNutL7liVJ/images/creating-packages/restapi-part08-ko/image-4.webp?fit=max&auto=format&n=8_YWxtQNutL7liVJ&q=85&s=62275732ffc395ebba136175791758fb" alt="restapi-part08-ko image 4" width="1119" height="906" data-path="images/creating-packages/restapi-part08-ko/image-4.webp" />
</Frame>

]\([https://cdn.filestackcontent.com/auto\_image//compress/cache=expiry:max/gWjHCjcfR3m0DPsgeZ8Q](https://cdn.filestackcontent.com/auto_image//compress/cache=expiry:max/gWjHCjcfR3m0DPsgeZ8Q))

Data Preview에서 대상 파일 목록이 올바른지 확인하고 `id, name`필드를 선택 하십시오.
\[

<Frame>
  <img src="https://mintcdn.com/integrateio/8_YWxtQNutL7liVJ/images/creating-packages/restapi-part08-ko/image-5.webp?fit=max&auto=format&n=8_YWxtQNutL7liVJ&q=85&s=2013954080de6f43a81f9d8dc73ccc7a" alt="restapi-part08-ko image 5" width="1200" height="969" data-path="images/creating-packages/restapi-part08-ko/image-5.webp" />
</Frame>

]\([https://cdn.filestackcontent.com/auto\_image//compress/cache=expiry:max/SbHB2HZZSaqwEs6NPp5X](https://cdn.filestackcontent.com/auto_image//compress/cache=expiry:max/SbHB2HZZSaqwEs6NPp5X))

*

**Filter 컴포넌트** 에서 정규 표현식의 매칭을 통해 파일 리스트로부터 연계 대상의 파일 ID와 파일명을 추출

\[

<Frame>
  <img src="https://mintcdn.com/integrateio/8_YWxtQNutL7liVJ/images/creating-packages/restapi-part08-ko/image-6.webp?fit=max&auto=format&n=8_YWxtQNutL7liVJ&q=85&s=0181c5b6171ec4b0fa4401f28cdd2a28" alt="restapi-part08-ko image 6" width="1200" height="875" data-path="images/creating-packages/restapi-part08-ko/image-6.webp" />
</Frame>

]\([https://cdn.filestackcontent.com/auto\_image//compress/cache=expiry:max/KErtdFxZSjub3RRE703l](https://cdn.filestackcontent.com/auto_image//compress/cache=expiry:max/KErtdFxZSjub3RRE703l))

* Conditions :`AND`

* Operator :`Text matches (regex)`

* Value/Expression :`^100_.*$`

*

**Select 컴포넌트**에서 `CCurl`커멘드를 이용해 GET 메소드에 의한 파일의 전송을 실시하고. 파일의 내용이 담김 body부분만을 가져옴
\[

<Frame>
  <img src="https://mintcdn.com/integrateio/8_YWxtQNutL7liVJ/images/creating-packages/restapi-part08-ko/image-7.webp?fit=max&auto=format&n=8_YWxtQNutL7liVJ&q=85&s=e1a0a4d080716f7ff2556b0de62f58c6" alt="restapi-part08-ko image 7" width="1200" height="874" data-path="images/creating-packages/restapi-part08-ko/image-7.webp" />
</Frame>

]\([https://cdn.filestackcontent.com/auto\_image//compress/cache=expiry:max/yOEfFf4bSz2TIDlohS09](https://cdn.filestackcontent.com/auto_image//compress/cache=expiry:max/yOEfFf4bSz2TIDlohS09))

* Expression :`CCurl(CONCAT('https://www.googleapis.com/drive/v3/files/', id, '?alt=media'), 'GET', '', '', '&lt;---구글_드라이브_ID--->')#'body'`

* 참고 : CCurl 명령에서는 Google 드라이브 커넥션의 Unique ID를 지정하십시오! !

* Alias :`api_response_body`

*

body부의 내용은 1개의 레코드로 인식하기에, **Select 컴포넌트** 상에서 **Flatten**함수를 사용해 복수의 레코드로 분리

\[

<Frame>
  <img src="https://mintcdn.com/integrateio/8_YWxtQNutL7liVJ/images/creating-packages/restapi-part08-ko/image-8.webp?fit=max&auto=format&n=8_YWxtQNutL7liVJ&q=85&s=dd47563125c016a7a09afab0980e381a" alt="restapi-part08-ko image 8" width="1200" height="878" data-path="images/creating-packages/restapi-part08-ko/image-8.webp" />
</Frame>

]\([https://cdn.filestackcontent.com/auto\_image//compress/cache=expiry:max/Mn8gdwqWQPec0zD8ITJ2](https://cdn.filestackcontent.com/auto_image//compress/cache=expiry:max/Mn8gdwqWQPec0zD8ITJ2))

* Expression :`Flatten(STRSPLITTOBAG(api_response_body, '\\n'))`

* Alias :`line`

*

**Filter 컴포넌트** 에서 정규식을 통해 헤더 레코드를 제거
\[

<Frame>
  <img src="https://mintcdn.com/integrateio/8_YWxtQNutL7liVJ/images/creating-packages/restapi-part08-ko/image-9.webp?fit=max&auto=format&n=8_YWxtQNutL7liVJ&q=85&s=30dbbc0904e5d5d93a6e2168a0a66f6f" alt="restapi-part08-ko image 9" width="1200" height="975" data-path="images/creating-packages/restapi-part08-ko/image-9.webp" />
</Frame>

]\([https://cdn.filestackcontent.com/auto\_image//compress/cache=expiry:max/omqY2u4SOaeE5BqbuDga](https://cdn.filestackcontent.com/auto_image//compress/cache=expiry:max/omqY2u4SOaeE5BqbuDga))

* 삭제할 헤더 :`seq,name/first,name/last,age,street,city,state,zip,dollar,pick,date`

* Conditions :`NOT`

* Value/Expression :`^seq.+$`

*

**Select 컴포넌트** 에서 **CSVSPLIT**함수를 사용해 레코드를 필드별로 분리된 배열로 변환
\[

<Frame>
  <img src="https://mintcdn.com/integrateio/8_YWxtQNutL7liVJ/images/creating-packages/restapi-part08-ko/image-10.webp?fit=max&auto=format&n=8_YWxtQNutL7liVJ&q=85&s=e46def4bee792301ca56e29e734ec566" alt="restapi-part08-ko image 10" width="1200" height="309" data-path="images/creating-packages/restapi-part08-ko/image-10.webp" />
</Frame>

]\([https://cdn.filestackcontent.com/auto\_image//compress/cache=expiry:max/NNxx2MatTWCa2U0sP2LO](https://cdn.filestackcontent.com/auto_image//compress/cache=expiry:max/NNxx2MatTWCa2U0sP2LO))

*

**Select 컴포넌트**에서 배열의 각 요소를 적합한 데이터 형식으로 캐스팅하여 변환
\[

<Frame>
  <img src="https://mintcdn.com/integrateio/8_YWxtQNutL7liVJ/images/creating-packages/restapi-part08-ko/image-11.webp?fit=max&auto=format&n=8_YWxtQNutL7liVJ&q=85&s=b8de4aa901f990cf01009dc472d6537d" alt="restapi-part08-ko image 11" width="1200" height="1515" data-path="images/creating-packages/restapi-part08-ko/image-11.webp" />
</Frame>

]\([https://cdn.filestackcontent.com/auto\_image//compress/cache=expiry:max/9g7mstR4KiDaa9pkTFQw](https://cdn.filestackcontent.com/auto_image//compress/cache=expiry:max/9g7mstR4KiDaa9pkTFQw))

*

Destination의 파일 스토리지 및 데이터베이스에 저장
\[

<Frame>
  <img src="https://mintcdn.com/integrateio/8_YWxtQNutL7liVJ/images/creating-packages/restapi-part08-ko/image-12.webp?fit=max&auto=format&n=8_YWxtQNutL7liVJ&q=85&s=906d918c578e72ab88a435994f6531d9" alt="restapi-part08-ko image 12" width="1200" height="628" data-path="images/creating-packages/restapi-part08-ko/image-12.webp" />
</Frame>

]\([https://cdn.filestackcontent.com/auto\_image//compress/cache=expiry:max/n9AN1xvT0W6dXvaQYcfP](https://cdn.filestackcontent.com/auto_image//compress/cache=expiry:max/n9AN1xvT0W6dXvaQYcfP))

**간단한 활용법**

파일 연계의 전후 관계가 없고 Google 드라이브로부터의 복수 파일 연계를 1개의 패키지로 관리하고 싶은 경우, 아래와 같은 활용이 가능합니다.

*

Google 드라이브에서 여러 파일을 동시에 연계 아래 그림과 같이 취득한 파일 목록에 여러 개의 **Clone 컴포넌트**의 연결에 의해, 하나의 패키지 실행으로 동시에 여러 파일을 연계할 수 있습니다.
\[

<Frame>
  <img src="https://mintcdn.com/integrateio/8_YWxtQNutL7liVJ/images/creating-packages/restapi-part08-ko/image-13.webp?fit=max&auto=format&n=8_YWxtQNutL7liVJ&q=85&s=1f6f6c5ae956ac8f05b8989b7b181eaa" alt="restapi-part08-ko image 13" width="1200" height="656" data-path="images/creating-packages/restapi-part08-ko/image-13.webp" />
</Frame>

]\([https://cdn.filestackcontent.com/auto\_image//compress/cache=expiry:max/YHEJsVDTRRq0yKZTg4re](https://cdn.filestackcontent.com/auto_image//compress/cache=expiry:max/YHEJsVDTRRq0yKZTg4re))

*

여러 곳의 Google 드라이브와의 파일 연계
여러개의 Google Drive 커넥션을 사용하여, 1개의 패키지에서 여러 곳의 Google 드라이브에서 동시에 파일 연계가 가능해 집니다. 쉽게 이야기 하면 위의 파일 연계가 옆으로 몇개씩 나열 되어 있는 형태라고 생각하시면 됩니다.

**패키지 템플릿을 사용할 때**

지금까지 설명한 내용에 대해서는 Xplenty의 데이터 플로의 템플릿으로 이미 제공하고 있습니다.
아래 그림과 같이 패키지 작성 화면에서 \*\*Template \*\*항목에서 바로 찾을 수 있습니다.
\[

<Frame>
  <img src="https://mintcdn.com/integrateio/8_YWxtQNutL7liVJ/images/creating-packages/restapi-part08-ko/image-14.webp?fit=max&auto=format&n=8_YWxtQNutL7liVJ&q=85&s=4d1c40af4c582aec42b5c15e16e6d3f2" alt="restapi-part08-ko image 14" width="1200" height="1445" data-path="images/creating-packages/restapi-part08-ko/image-14.webp" />
</Frame>

]\([https://cdn.filestackcontent.com/auto\_image//compress/cache=expiry:max/86DZNylTjuwNuYlVOLMw](https://cdn.filestackcontent.com/auto_image//compress/cache=expiry:max/86DZNylTjuwNuYlVOLMw))

템플릿의 경우, 두 개의 사용자 변수 설정만으로 바로 사용할 수 있습니다.
\[

<Frame>
  <img src="https://mintcdn.com/integrateio/8_YWxtQNutL7liVJ/images/creating-packages/restapi-part08-ko/image-15.webp?fit=max&auto=format&n=8_YWxtQNutL7liVJ&q=85&s=82023d885d467d1b059121173fff6ec1" alt="restapi-part08-ko image 15" width="1200" height="969" data-path="images/creating-packages/restapi-part08-ko/image-15.webp" />
</Frame>

]\([https://cdn.filestackcontent.com/auto\_image//compress/cache=expiry:max/OMgerZXtR3mqLLtIue26](https://cdn.filestackcontent.com/auto_image//compress/cache=expiry:max/OMgerZXtR3mqLLtIue26))

* query\_string : 쿼리 문자열 지정

* google\_drive\_connection\_id : Google 드라이브 연결의 Unique ID 지정

마지막으로

편리한 Google 드라이브를 통한 파일 연동은 특히 비즈니스 부서에서 매우 일반적인 사용법입니다.
Xplenty는 프로그래밍 경험이 있는 분은 물론, 비즈니스 부서에서 프로그래밍 경험이 거의 없는 분들도 곧바로 사용할 수 있는 DX 전문의 로우 코드 툴입니다.

Xplenty를 사용해 파일 제휴와 같은 간단한 업무로부터 귀사의 자동화를 스스로 해 보지 않으시겠습니까?
[저희 홈페이지](https://www.integrate.io/ko/) 에서 부담없이 [프리 트라이얼](https://try.integrate.io/kr-demo/) 과 [데모 신청](https://try.integrate.io/kr-demo/) 을 할 수 있습니다. 여러분의 많은 신청을 기다리고 있습니다. 

\<!-- notionvc: bfa69f29-4485-4776-9d10-43c46c9e3083 -->

##

\<!-- Google Tag Manager hidden fields -->

\<!-- End Google Tag Manager hidden fields -->

\<!-- Text input-->

Get Started

Free 7-day trial. Easy setup. Cancel any time
