# DPE SDKを使用したリモートストレージからのファイルの取得

この例では、**リモートソース**からデータストアにファイルを取得する方法について説明します。  
以下のサンプルは、[カスタムアクション](/jp/product/dpe/actions/custom/index)のコンテキストで記述されています。必要に応じて調整してください。


```python
import sys
import pandas as pd

from logging import getLogger
from forepaas.worker.connect import connect

logger = logging.getLogger(__name__)
def extract_func(event):
    try:
        source_address = "dwh/mysftp_source/"
        bucket_destination_name = "my.destination.bucket"

        # connect to the source
        source_connector = connect(source_address)

        # connect to the bucket
        bucket_connector = connect("data_store/{}".format(bucket_destination_name))
   
        # list files from source
        files = source_connector.list()

        # filename of file to retrieve
        filename = "filename_2020-01-01.csv"

        # retrieve the file from the source server...
        source_connector.get(filename=filename)
        # ... it has been saved in /tmp/ with the same filename
        local_filepath = "/tmp/{}".format(filename)

        # put file into a bucket
        bucket_connector.fput(filename, local_filepath)

        # disconnect from datastore and remote source
        del bucket_connector
        del source_connector

    except Exception as err: 
        raise Exception("err:{} L:{}".format(err,sys.exc_info()[2].tb_lineno))
    
```

> **ヒント**：これは、[FTP](/jp/product/data-manager/collect/connectors/ftp/index)、[Dropbox](/jp/product/data-manager/collect/connectors/dropbox/index)、[OneDrive](/jp/product/data-manager/collect/connectors/onedrive/index)など、任意の`source`プロトコルで使用できます。







    













