File tree Expand file tree Collapse file tree 2 files changed +16
-3
lines changed Expand file tree Collapse file tree 2 files changed +16
-3
lines changed Original file line number Diff line number Diff line change @@ -885,6 +885,18 @@ describe('Parse.File testing', () => {
885
885
await expectAsync ( file . save ( { sessionToken : authUser . getSessionToken ( ) } ) ) . toBeResolved ( ) ;
886
886
} ) ;
887
887
888
+ fit ( 'allows file upload with master key' , async ( ) => {
889
+ await reconfigureServer ( {
890
+ fileUpload : {
891
+ enableForPublic : false ,
892
+ enableForAnonymousUser : false ,
893
+ enableForAuthenticatedUser : false ,
894
+ } ,
895
+ } ) ;
896
+ let file = new Parse . File ( 'hello.txt' , data , 'text/plain' ) ;
897
+ await expectAsync ( file . save ( { useMasterKey : true } ) ) . toBeResolved ( ) ;
898
+ } ) ;
899
+
888
900
it ( 'rejects all file uploads' , async ( ) => {
889
901
await reconfigureServer ( {
890
902
fileUpload : {
Original file line number Diff line number Diff line change @@ -95,22 +95,23 @@ export class FilesRouter {
95
95
async createHandler ( req , res , next ) {
96
96
const config = req . config ;
97
97
const user = req . auth . user ;
98
+ const isMaster = req . auth . isMaster ;
98
99
const isLinked = user && Parse . AnonymousUtils . isLinked ( user ) ;
99
- if ( ! config . fileUpload . enableForAnonymousUser && isLinked ) {
100
+ if ( ! isMaster && ! config . fileUpload . enableForAnonymousUser && isLinked ) {
100
101
next ( new Parse . Error (
101
102
Parse . Error . FILE_SAVE_ERROR ,
102
103
'File upload by anonymous user is disabled.'
103
104
) ) ;
104
105
return ;
105
106
}
106
- if ( ! config . fileUpload . enableForAuthenticatedUser && ! isLinked && user ) {
107
+ if ( ! isMaster && ! config . fileUpload . enableForAuthenticatedUser && ! isLinked && user ) {
107
108
next ( new Parse . Error (
108
109
Parse . Error . FILE_SAVE_ERROR ,
109
110
'File upload by authenticated user is disabled.'
110
111
) ) ;
111
112
return ;
112
113
}
113
- if ( ! config . fileUpload . enableForPublic && ! user ) {
114
+ if ( ! isMaster && ! config . fileUpload . enableForPublic && ! user ) {
114
115
next ( new Parse . Error ( Parse . Error . FILE_SAVE_ERROR , 'File upload by public is disabled.' ) ) ;
115
116
return ;
116
117
}
You can’t perform that action at this time.
0 commit comments