full single file upload working
parent
f0c82217fd
commit
aa5f7f2f9e
@ -0,0 +1 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?><sqlb_project><db path="/home/spike/projects/bit4sat/server/db-storage/bit4sat.sqlite" readonly="0" foreign_keys="1" case_sensitive_like="0" temp_store="0" wal_autocheckpoint="1000" synchronous="1"/><attached/><window><main_tabs open="structure browser query pragmas" current="1"/></window><tab_structure><column_width id="0" width="300"/><column_width id="1" width="0"/><column_width id="2" width="100"/><column_width id="3" width="2010"/><column_width id="4" width="0"/><expanded_item id="0" parent="1"/><expanded_item id="1" parent="1"/><expanded_item id="2" parent="1"/><expanded_item id="3" parent="1"/></tab_structure><tab_browse><current_table name="upload_with_status"/><default_encoding codec=""/><browse_table_settings><table schema="main" name="upload" show_row_id="0" encoding="" plot_x_axis="" unlock_view_pk=""><sort/><column_widths><column index="1" value="275"/><column index="2" value="556"/><column index="3" value="256"/></column_widths><filter_values/><conditional_formats/><display_formats><column index="7" value=""/></display_formats><hidden_columns/><plot_y_axes/></table><table schema="main" name="upload_status" show_row_id="0" encoding="" plot_x_axis="" unlock_view_pk=""><sort/><column_widths/><filter_values/><conditional_formats/><display_formats/><hidden_columns/><plot_y_axes/></table><table schema="main" name="upload_with_status" show_row_id="0" encoding="" plot_x_axis="" unlock_view_pk=""><sort/><column_widths><column index="7" value="0"/><column index="8" value="0"/></column_widths><filter_values/><conditional_formats/><display_formats/><hidden_columns><column index="7" value="1"/><column index="8" value="1"/></hidden_columns><plot_y_axes/></table></browse_table_settings></tab_browse><tab_sql><sql name="SQL 1">SELECT EXISTS (SELECT upload_id FROM upload WHERE upload_id = '1Ijbco3pYIrl2VzTslERxszEHG1');</sql><sql name="SQL 2">SELECT * FROM upload JOIN upload_status ON upload.status = upload_status.type;</sql><current_tab id="1"/></tab_sql></sqlb_project>
|
@ -0,0 +1,19 @@
|
||||
package utils
|
||||
|
||||
import (
|
||||
"log"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func JSONErr(c *gin.Context, status int, msg string) {
|
||||
c.AbortWithStatusJSON(status, gin.H{
|
||||
"status": status,
|
||||
"error": msg,
|
||||
})
|
||||
}
|
||||
|
||||
func JSONErrPriv(c *gin.Context, status int, err error) {
|
||||
log.Println(err)
|
||||
JSONErr(c, status, "")
|
||||
}
|
@ -0,0 +1,35 @@
|
||||
package utils
|
||||
|
||||
import "testing"
|
||||
|
||||
type CleanName struct {
|
||||
name string
|
||||
ext string
|
||||
}
|
||||
|
||||
func TestCleanFileName(t *testing.T) {
|
||||
|
||||
tests := map[string]CleanName{
|
||||
"noext": CleanName{"noext", ""},
|
||||
"with.ext": CleanName{"with", ".ext"},
|
||||
"path/with.ext": CleanName{"with", ".ext"},
|
||||
"path/noext": CleanName{"noext", ""},
|
||||
}
|
||||
|
||||
for name, expected := range tests {
|
||||
|
||||
t.Run(name, func(t *testing.T) {
|
||||
|
||||
resName, resExt := CleanFileName(name)
|
||||
|
||||
if resName != expected.name {
|
||||
t.Fail()
|
||||
}
|
||||
|
||||
if resExt != expected.ext {
|
||||
t.Fail()
|
||||
}
|
||||
|
||||
})
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue