0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

cli-kintone を使った添付ファイルの移行方法のメモ

Last updated at Posted at 2021-03-10

kintoneに添付ファイルをアップロードする方法についてのメモです。

移行データの準備

  • t01は作業フォルダ
  • Attachmentsに添付ファイルを配置
  • Attachments/01の01を添付ファイルをアップロードするキー項目とする想定
  • upload.csvはcli-kintoneで読みこむアップロード用のデータファイル
  • upload.shはcli-kintoneの処理を書いたシェルスクリプト
t01
├── Attachments
│   ├── 01
│   │   ├── sample1.txt
│   │   └── sample2.txt
│   └── 02
│       └── sample1.txt
├── upload.csv
└── upload.sh

kintoneアプリ

スクリーンショット 2021-03-10 20.49.38.png

upload.csv

レコードに複数のファイルをアップロードする場合、ディレクトリを作成してそこに複数のファイルを設置する。
CSVにはcli-kintoneのアップロードファイルのベースパスをパラメータで渡して、ファイルはベースパスからの相対パスを設定する。
複数ファイルの場合は、CRで区切るようにする。

upload.csv
"Id","file"
"001","01/sample1.txt
01/sample2.txt"
"002","02/sample1.txt"

upload.sh

upload.sh
# !/bin/bash

appId=<アプリId>
apiToken='<APIトークン>'
domain='<ドメイン>'
attachmentFileDir='<添付ファイルディレクトリ>'
inputFilePath='<アップロードCSVファイル>'

cli-kintone --import -a "$appId" -t "$apiToken" -d "$domain" -b "$attachmentFileDir" -f "$inputFilePath"

実行

$ ./upload.sh
[2021-03-10 20:41:30]: Start from lines: 1 - 3 => SUCCESS
[2021-03-10 20:41:30]: DONE

結果

スクリーンショット 2021-03-10 22.12.25.png

スクリーンショット 2021-03-10 22.14.18.png

参考

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?