Added File model (still missing edit/remove), fixed uploading to space always failing, added /upload endpoint to rpdata-grapihql server

This commit is contained in:
2018-06-10 20:11:32 +02:00
parent 18cb6f14aa
commit 1978883cd7
3 changed files with 185 additions and 1 deletions
+8 -1
View File
@@ -59,7 +59,7 @@ func UploadFile(ctx context.Context, folder string, name string, mimeType string
return "", err
}
_, err = spaceClient.StatObject(spaceBucket, path, minio.StatObjectOptions{})
_, err = spaceClient.StatObject(spaceBucket, spaceRoot+"/"+path, minio.StatObjectOptions{})
if err != nil {
return "", err
}
@@ -67,6 +67,13 @@ func UploadFile(ctx context.Context, folder string, name string, mimeType string
return path, nil
}
// RemoveFile removes a file from the space
func RemoveFile(folder string, name string) error {
path := folder + "/" + name
return spaceClient.RemoveObject(spaceBucket, spaceRoot+"/"+path)
}
// DownloadFile opens a file for download, using the same path format as the UploadFile function. Remember to Close it!
func DownloadFile(ctx context.Context, path string) (io.ReadCloser, error) {
return spaceClient.GetObjectWithContext(ctx, spaceBucket, spaceRoot+"/"+path, minio.GetObjectOptions{})