LoginSignup

This article is a Private article. Only a writer and users who know the URL can access it.
Please change open range to public in publish setting if you want to share this article with other users.

More than 5 years have passed since last update.

[RescaleAPI] Fileのアップロード

Last updated at Posted at 2017-02-13

0. 前提

事前に下記が実施されていることを前提とします。設定済みであれば飛ばしてOKです。

1. RescaleAPI Fileのアップロード

以下のスクリプトを ${script}/rescale-uploadfile.sh という名前で保存します。

1.1 スクリプトの作成

rescale-uploadfile.shの作成
vi ${script}/rescale-uploadfile.sh
source
#!/bin/sh

filename=$1
token=${RESCALE_API_TOKEN}

curl -s -X POST \
-H "Content-Type:multipart/form-data" \
-H "Authorization: Token ${token}" \
-F "file=@${filename}" \
https://platform.rescale.jp/api/v2/files/contents/
実行権限付与
chmod +x ${script}/rescale-uploadfile.sh

1.2 実行例 ファイルをアップロードし、そのfileIdを取得する

使用する変数を確認します。

変数の確認
cat << ETX

RESCALE_API_TOKEN: ${RESCALE_API_TOKEN}
uploadFile: ${uploadFile}

ETX
fileIdの取得
uploadJson=$(rescale-uploadfile.sh ${uploadFile})
fileId=$(echo ${uploadJson} | jq -r .id) && echo ${fileId}
結果例
uunrm
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