Skip to content

Commit 330fe1f

Browse files
author
Michael Recachinas
committed
Add rawFile support for minio
1 parent 4d075f5 commit 330fe1f

File tree

1 file changed

+29
-2
lines changed

1 file changed

+29
-2
lines changed

sigplot_data_service.go

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2001,12 +2001,39 @@ func (s *fileSystemServer) ServeHTTP(w http.ResponseWriter, r *http.Request) {
20012001
doneCh := make(chan struct{})
20022002
defer close(doneCh)
20032003

2004+
objectFd, _ := minioClient.GetObject(currentLocation.MinioBucket, urlPath, minio.GetObjectOptions{})
2005+
if objectFd != nil {
2006+
// File exists and is a file
2007+
info, err := objectFd.Stat()
2008+
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")
2021+
} 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", "*")
2026+
2027+
http.ServeContent(w, r, info.Key, time.Now(), objectFd)
2028+
return
2029+
}
2030+
20042031
var filelist []fileObj
2005-
objectCh := minioClient.ListObjects(currentLocation.MinioBucket, urlPath,false, doneCh)
2032+
objectCh := minioClient.ListObjects(currentLocation.MinioBucket, urlPath, false, doneCh)
20062033
for object := range objectCh {
20072034
if object.Err != nil {
20082035
log.Println(object.Err)
2009-
w.WriteHeader(500)
2036+
w.WriteHeader(400)
20102037
return
20112038
}
20122039

0 commit comments

Comments
 (0)