組み込みジョブuploadのto_fieldオプション指定について
下記内容について、ご教示ください。
■環境
CentOS Linux release 7.9.2009
Kompira Enterprise 1.6.2.post5
■内容
・前提
添付ファイルフィールドを持つオブジェクトを作成
オブジェクト:sample_obj
フィールド種別
file : File
files: Array<File>
・やりたいこと
Kompiraサーバのローカルに配置したファイルを上記の添付ファイルフィールドにアップロードしたい
・上記のfileフィールド(File型)へのアップロードはOK(マニュアルの記載例通り)
・上記のfilesフィールド(Array<File>型)へのアップロードが上手くいかないので、
こちらの方法をご教示いただきたい
下記で試してみるもエラー
upload(from_path='/tmp/sample.txt', to_object=./sample_obj, to_field='files')
→[ERROR] Failed to get result of LOAD task: ValidationError: ['Invalid file object: name']
upload(from_path='/tmp/sample.txt', to_object=./sample_obj, to_field= "files[0]")
→[ERROR] Failed to get result of LOAD task: KeyError: 'files[0]'
downloadの方は下記でArray<File>型からファイル取得できたのですが、
上記のuploadが上手くいかないため、指定方法についてご教示いただけないでしょうか
download(from_file=./sample_obj.files[0], to_path='/tmp/')
お手数かけますが、よろしくお願いします。
-
正式なコメント
フィックスポイントの高橋です。
ご指摘ありがとうございます。確認しましたところ、`upload()` 組み込みジョブが `Array<File>` や `Dictionary<File>` 型フィールドへのファイルアップロードに対応できていないことが分かりました。
upload() 組み込みジョブ自体については、今後改善を検討したいと思います。
回避策の一案としては、cat コマンドなどでファイルの内容を取得して、ジョブフローで配列や辞書フィールドを更新するということは可能です。なおこのとき、name および data という要素を持つファイル構造の辞書データを作成して、フィールドに書き込んでいます。
|from_path = '/etc/system-release'|
|to_object = ./test_files_data|
|upload_name = 'system-release'|
|array_field = 'file_list'|
|dict_field = 'file_dict'|
# cat コマンドでファイルを取得 (バイナリで取得するため __raw_stdout__=true)
[__raw_stdout__ = true] ->
["cat $from_path"] ->
[file = {name=upload_name, data=$RESULT}] ->
# Array<File> フィールドにアップロード(要素の追加)
[to_object[array_field].add_item: file] ->
# Dictionary<File> フィールドにアップロード(要素の上書)
[file >> to_object[dict_field][from_path]]参考になさってみてください。
コメントアクション
サインインしてコメントを残してください。
コメント
4件のコメント