9
9
using Microsoft . Azure . WebJobs . Host . Bindings . Path ;
10
10
using Microsoft . Azure . WebJobs . Host . Bindings . Runtime ;
11
11
using Microsoft . Azure . WebJobs . Script . Description ;
12
+ using Microsoft . WindowsAzure . Storage . Blob ;
12
13
13
14
namespace Microsoft . Azure . WebJobs . Script . Binding
14
15
{
@@ -53,12 +54,14 @@ public override async Task BindAsync(BindingContext context)
53
54
await BindStreamAsync ( context . Value , Access , context . Binder , runtimeContext ) ;
54
55
}
55
56
56
- public override Collection < CustomAttributeBuilder > GetCustomAttributes ( )
57
+ public override Collection < CustomAttributeBuilder > GetCustomAttributes ( Type parameterType )
57
58
{
58
59
Collection < CustomAttributeBuilder > attributes = new Collection < CustomAttributeBuilder > ( ) ;
59
60
61
+ FileAccess access = GetAttributeAccess ( parameterType ) ;
62
+
60
63
var constructorTypes = new Type [ ] { typeof ( string ) , typeof ( FileAccess ) } ;
61
- var constructorArguments = new object [ ] { Path , Access } ;
64
+ var constructorArguments = new object [ ] { Path , access } ;
62
65
var attribute = new CustomAttributeBuilder ( typeof ( BlobAttribute ) . GetConstructor ( constructorTypes ) , constructorArguments ) ;
63
66
64
67
attributes . Add ( attribute ) ;
@@ -70,5 +73,18 @@ public override Collection<CustomAttributeBuilder> GetCustomAttributes()
70
73
71
74
return attributes ;
72
75
}
76
+
77
+ private FileAccess GetAttributeAccess ( Type parameterType )
78
+ {
79
+ // The types bellow only support Read/Write access.
80
+ // When using them we ignore the acces and always assume ReadWrite
81
+ if ( parameterType == typeof ( ICloudBlob ) || parameterType == typeof ( CloudBlockBlob ) ||
82
+ parameterType == typeof ( CloudPageBlob ) || parameterType == typeof ( CloudBlobDirectory ) )
83
+ {
84
+ return FileAccess . ReadWrite ;
85
+ }
86
+
87
+ return Access ;
88
+ }
73
89
}
74
90
}
0 commit comments