Fix attachment management for all supported types

* Add missing expr.Bytes expr. type
* Fix attachment upload when []bytes used (missing type, improper
  size calculation)
* Fix attachment upload when ReadSeeker used (missing size calculation)
* Fix attachment upload when Reader used (missing logic, missing size
  calculation)
This commit is contained in:
Tomaž Jerman
2022-04-19 14:32:04 +02:00
parent 0b02b3acb6
commit 6fd2288dfd
5 changed files with 256 additions and 1 deletions
@@ -0,0 +1,9 @@
namespaces:
ns1:
name: Namespace#1
modules:
mod1:
name: Module#1
fields:
f1: { label: 'Field1', kind: 'File' }
@@ -0,0 +1,96 @@
workflows:
attachments:
enabled: true
trace: true
triggers:
- enabled: true
stepID: 11
steps:
- stepID: 11
kind: function
ref: composeRecordsNew
arguments:
- { target: module, type: Handle, value: "mod1" }
- { target: namespace, type: Handle, value: "ns1" }
results:
- { target: attachableString, expr: "record" }
- stepID: 12
kind: function
ref: composeRecordsNew
arguments:
- { target: module, type: Handle, value: "mod1" }
- { target: namespace, type: Handle, value: "ns1" }
results:
- { target: attachableReader, expr: "record" }
- stepID: 13
kind: function
ref: composeRecordsNew
arguments:
- { target: module, type: Handle, value: "mod1" }
- { target: namespace, type: Handle, value: "ns1" }
results:
- { target: attachableReadSeeker, expr: "record" }
- stepID: 14
kind: function
ref: composeRecordsNew
arguments:
- { target: module, type: Handle, value: "mod1" }
- { target: namespace, type: Handle, value: "ns1" }
results:
- { target: attachableBytes, expr: "record" }
# Store attachment from given string
- stepID: 20
kind: function
ref: attachmentCreate
arguments:
- { target: content, type: String, expr: "sourceString" }
- { target: name, type: String, value: "att.txt" }
- { target: resource, type: ComposeRecord, expr: "attachableString" }
- { target: fieldName, type: String, value: "f1" }
results:
- { target: attachedString, expr: "attachment" }
- stepID: 21
kind: function
ref: attachmentCreate
arguments:
- { target: content, type: Reader, expr: "sourceReader" }
- { target: name, type: String, value: "att.txt" }
- { target: resource, type: ComposeRecord, expr: "attachableReader" }
- { target: fieldName, type: String, value: "f1" }
results:
- { target: attachedReader, expr: "attachment" }
- stepID: 22
kind: function
ref: attachmentCreate
arguments:
- { target: content, type: Reader, expr: "sourceReadSeeker" }
- { target: name, type: String, value: "att.txt" }
- { target: resource, type: ComposeRecord, expr: "attachableReadSeeker" }
- { target: fieldName, type: String, value: "f1" }
results:
- { target: attachedReadSeeker, expr: "attachment" }
- stepID: 23
kind: function
ref: attachmentCreate
arguments:
- { target: content, type: Bytes, expr: "sourceBytes" }
- { target: name, type: String, value: "att.txt" }
- { target: resource, type: ComposeRecord, expr: "attachableBytes" }
- { target: fieldName, type: String, value: "f1" }
results:
- { target: attachedBytes, expr: "attachment" }
paths:
- { parentID: 11, childID: 12 }
- { parentID: 12, childID: 13 }
- { parentID: 13, childID: 14 }
- { parentID: 14, childID: 20 }
- { parentID: 20, childID: 21 }
- { parentID: 21, childID: 22 }
- { parentID: 22, childID: 23 }