@@ -1923,14 +1923,7 @@ func (s *fileSystemServer) ServeHTTP(w http.ResponseWriter, r *http.Request) {
19231923 }
19241924
19251925 locationName := pathData [3 ]
1926- urlPath := ""
1927- for i := 4 ; i < len (pathData ); i ++ {
1928- urlPath = urlPath + pathData [i ] + "/"
1929- }
1930-
1931- if string (r .URL .Path [len (r .URL .Path )- 1 ]) != "/" {
1932- urlPath = strings .TrimSuffix (urlPath , "/" )
1933- }
1926+ urlPath := filepath .Join (pathData [4 :]... )
19341927
19351928 var currentLocation Location
19361929 for i := range configuration .LocationDetails {
@@ -2001,31 +1994,36 @@ func (s *fileSystemServer) ServeHTTP(w http.ResponseWriter, r *http.Request) {
20011994 doneCh := make (chan struct {})
20021995 defer close (doneCh )
20031996
2004- objectFd , _ := minioClient .GetObject (currentLocation .MinioBucket , urlPath , minio.GetObjectOptions {})
1997+ if urlPath == "" {
1998+ urlPath += "/"
1999+ }
2000+
2001+ objectFd , err := minioClient .GetObject (currentLocation .MinioBucket , urlPath , minio.GetObjectOptions {})
2002+ if err != nil {
2003+ log .Println (err )
2004+ }
20052005 if objectFd != nil {
20062006 // File exists and is a file
20072007 info , err := objectFd .Stat ()
20082008 if err != nil {
2009- log .Println (err )
2010- w .WriteHeader (400 )
2011- return
2012- }
2013- if info .Err != nil {
2014- log .Println (info .Err )
2015- w .WriteHeader (400 )
2016- return
2017- }
2018-
2019- if strings .HasSuffix (info .Key , ".tmp" ) || strings .HasSuffix (info .Key , ".prm" ) {
2020- w .Header ().Add ("Content-Type" , "application/bluefile" )
2009+ log .Println ("Error performing stat on object:" , err )
2010+ if ! strings .HasSuffix (urlPath , "/" ) {
2011+ urlPath += "/"
2012+ }
2013+ } else if info .Err != nil {
2014+ log .Println (info .Err , info .Key )
20212015 } else {
2022- w .Header ().Add ("Content-Type" , "application/binary" )
2023- }
2024- w .Header ().Add ("Access-Control-Allow-Origin" , "*" )
2025- w .Header ().Add ("Access-Control-Expose-Headers" , "*" )
2016+ if strings .HasSuffix (info .Key , ".tmp" ) || strings .HasSuffix (info .Key , ".prm" ) {
2017+ w .Header ().Add ("Content-Type" , "application/bluefile" )
2018+ } else {
2019+ w .Header ().Add ("Content-Type" , "application/binary" )
2020+ }
2021+ w .Header ().Add ("Access-Control-Allow-Origin" , "*" )
2022+ w .Header ().Add ("Access-Control-Expose-Headers" , "*" )
20262023
2027- http .ServeContent (w , r , info .Key , time .Now (), objectFd )
2028- return
2024+ http .ServeContent (w , r , info .Key , time .Now (), objectFd )
2025+ return
2026+ }
20292027 }
20302028
20312029 var filelist []fileObj
@@ -2038,7 +2036,7 @@ func (s *fileSystemServer) ServeHTTP(w http.ResponseWriter, r *http.Request) {
20382036 }
20392037
20402038 file := fileObj {
2041- Filename : object .Key ,
2039+ Filename : filepath . Base ( object .Key ) ,
20422040 }
20432041 if strings .HasSuffix (file .Filename , "/" ) {
20442042 file .Type = "directory"
0 commit comments