@@ -26,9 +26,16 @@ module.exports = function (options) {
2626 UploadHandler . prototype . noCache = function ( ) {
2727 this . res . set ( {
2828 'Pragma' : 'no-cache' ,
29- 'Cache-Control' : 'no-store, no-cache, must-revalidate' ,
30- // 'Content-Disposition': 'inline; filename="files.json"'
29+ 'Cache-Control' : 'no-store, no-cache, must-revalidate'
3130 } ) ;
31+ if ( ( this . req . get ( "Accept" ) || "" ) . indexOf ( "application/json" ) != - 1 ) {
32+ this . res . set ( {
33+ 'Content-Type' : 'application/json' ,
34+ 'Content-Disposition' : 'inline; filename="files.json"'
35+ } ) ;
36+ } else {
37+ this . res . set ( { 'Content-Type' : 'text/plain' } ) ;
38+ }
3239 } ;
3340
3441 UploadHandler . prototype . get = function ( ) {
@@ -177,18 +184,12 @@ module.exports = function (options) {
177184 var filepath = path . join ( options . uploadDir ( ) , fileName ) ;
178185 if ( filepath . indexOf ( options . uploadDir ( ) ) !== 0 ) {
179186 self . emit ( 'delete' , fileName ) ;
180- self . callback ( { success : false } ) ;
187+ self . callback ( { success : false } ) ;
181188 return ;
182189 }
183190 fs . unlink ( filepath , function ( ex ) {
184191 _ . each ( options . imageVersions , function ( value , version ) {
185- var versionfilepath = path . join ( options . uploadDir ( ) , version , fileName ) ;
186- if ( versionfilepath . indexOf ( options . uploadDir ( ) ) !== 0 ) {
187- self . emit ( 'delete' , fileName ) ;
188- self . callback ( { success : false } ) ;
189- return ;
190- }
191- fs . unlink ( versionfilepath ) ;
192+ fs . unlink ( path . join ( options . uploadDir ( ) , version , fileName ) ) ;
192193 } ) ;
193194 self . emit ( 'delete' , fileName ) ;
194195 self . callback ( { success : ! ex } ) ;
0 commit comments