@@ -80,7 +80,7 @@ func getValidFileNameWithDupIndex(path string, filename string, duplicateIndex i
80
80
81
81
// path doesn't exist so we can return this path
82
82
if _ , err := os .Stat (fullpath ); os .IsNotExist (err ) {
83
- return strings .ToUpper (dupStr + filename )
83
+ return strings .ToLower (dupStr + filename )
84
84
}
85
85
86
86
//otherwise increase file index and
@@ -378,15 +378,16 @@ func ProcessImageWithEndpoint(endpoint string, ext string, imgData io.Reader, op
378
378
if err != nil {
379
379
return nil , fmt .Errorf ("statuscode %v" , err )
380
380
}
381
- if res .StatusCode != 200 {
382
- return nil , fmt .Errorf ("failed with status code: %d" , res .StatusCode )
383
- }
384
381
defer res .Body .Close ()
385
382
386
383
b , err = ioutil .ReadAll (res .Body )
387
384
if err != nil {
388
385
return nil , fmt .Errorf ("failed reading final bytes %v" , err )
389
386
}
387
+
388
+ if res .StatusCode != 200 {
389
+ return nil , fmt .Errorf ("failed with status code: %d and message %s" , res .StatusCode , string (b ))
390
+ }
390
391
return b , nil
391
392
}
392
393
@@ -422,7 +423,6 @@ func (fs *LocalFileStorage) OpenFile(filename string) (b []byte, fileName string
422
423
}
423
424
424
425
func (fs * LocalFileStorage ) SaveFile (filename string , r io.Reader ) (fileName string , url string , err error ) {
425
- filename = getValidFileName (fs .AttachmentsFolder , filename )
426
426
f , err := os .OpenFile (fs .AttachmentsFolder + filename , os .O_RDWR | os .O_CREATE , 0666 )
427
427
if err != nil {
428
428
return "" , "" , fmt .Errorf ("Failed to create a file on the filesystem: %v" , err )
0 commit comments