11
11
using System . Threading . Tasks ;
12
12
using Microsoft . Azure . WebJobs . Script . Description ;
13
13
using Microsoft . Azure . WebJobs . Script . Extensibility ;
14
+ using Newtonsoft . Json ;
14
15
using Newtonsoft . Json . Linq ;
15
16
16
17
namespace Microsoft . Azure . WebJobs . Script . Binding
@@ -46,6 +47,8 @@ public override async Task BindAsync(BindingContext context)
46
47
{
47
48
context . Attributes = _attributes . ToArray ( ) ;
48
49
50
+ object inputValue = null ;
51
+
49
52
if ( _binding . DefaultType == typeof ( IAsyncCollector < byte [ ] > ) )
50
53
{
51
54
await BindAsyncCollectorAsync < byte [ ] > ( context ) ;
@@ -67,13 +70,32 @@ public override async Task BindAsync(BindingContext context)
67
70
var result = await context . Binder . BindAsync < JObject > ( _attributes . ToArray ( ) ) ;
68
71
if ( Access == FileAccess . Read )
69
72
{
70
- context . Value = result ;
73
+ inputValue = result ;
71
74
}
72
75
}
76
+ else if ( _binding . DefaultType == typeof ( JArray ) )
77
+ {
78
+ JArray entityArray = await context . Binder . BindAsync < JArray > ( _attributes . ToArray ( ) ) ;
79
+ inputValue = entityArray ;
80
+ }
73
81
else
74
82
{
75
83
throw new NotSupportedException ( $ "ScriptBinding type { _binding . DefaultType } is not supported") ;
76
84
}
85
+
86
+ if ( inputValue != null )
87
+ {
88
+ if ( context . DataType == DataType . Stream )
89
+ {
90
+ // In file-based scripting (like Python), arguments may need to be copied to the file system.
91
+ var inputStream = ( Stream ) context . Value ;
92
+ ConvertValueToStream ( inputValue , inputStream ) ;
93
+ }
94
+ else
95
+ {
96
+ context . Value = inputValue ;
97
+ }
98
+ }
77
99
}
78
100
79
101
internal static CustomAttributeBuilder GetAttributeBuilder ( Attribute attribute )
0 commit comments