Toggle navigation
Toggle navigation
This project
Loading...
Sign in
2020-2-capstone-design1
/
JJS_project1
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
Ma Suhyeon
2020-11-07 01:16:04 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
0794f28a92c7e977764f27902fd7fad607508e2a
0794f28a
1 parent
576fcdc4
Implement extraction upload
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
49 additions
and
1 deletions
source/server/.gitignore
source/server/app.go
source/server/extraction.go
source/server/go.mod
source/server/go.sum
source/server/.gitignore
View file @
0794f28
...
...
@@ -34,4 +34,5 @@
# End of https://www.toptal.com/developers/gitignore/api/go,vscode
__debug_bin
config.json
\ No newline at end of file
config.json
data
\ No newline at end of file
...
...
source/server/app.go
View file @
0794f28
...
...
@@ -32,6 +32,7 @@ func NewApp(config Config) *App {
app
.
router
=
mux
.
NewRouter
()
app
.
router
.
HandleFunc
(
"/users"
,
app
.
PostUsers
)
.
Methods
(
"POST"
)
app
.
router
.
HandleFunc
(
"/users/tokens"
,
app
.
PostTokens
)
.
Methods
(
"POST"
)
app
.
router
.
Handle
(
"/extractions"
,
app
.
WithAuth
(
app
.
PostExtractions
))
.
Methods
(
"Post"
)
return
app
}
...
...
source/server/extraction.go
0 → 100644
View file @
0794f28
package
main
import
(
"fmt"
"io"
"net/http"
"os"
"strings"
"github.com/google/uuid"
)
func
(
app
*
App
)
PostExtractions
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
userNo
:=
r
.
Context
()
.
Value
(
PropUserNo
)
.
(
uint64
)
r
.
ParseMultipartForm
(
32
<<
20
)
form
,
_
,
err
:=
r
.
FormFile
(
"file"
)
if
err
!=
nil
{
WriteError
(
w
,
http
.
StatusInternalServerError
,
"Unknown error"
)
return
}
defer
form
.
Close
()
dir
:=
fmt
.
Sprintf
(
"data/%d"
,
userNo
)
os
.
MkdirAll
(
dir
,
0644
)
name
:=
strings
.
Replace
(
uuid
.
New
()
.
String
(),
"-"
,
""
,
-
1
)
file
,
err
:=
os
.
Create
(
fmt
.
Sprintf
(
"%s/%s"
,
dir
,
name
))
if
err
!=
nil
{
WriteError
(
w
,
http
.
StatusInternalServerError
,
"Unknown error"
)
return
}
defer
file
.
Close
()
_
,
err
=
io
.
Copy
(
file
,
form
)
if
err
!=
nil
{
WriteError
(
w
,
http
.
StatusInternalServerError
,
"Unknown error"
)
return
}
w
.
Write
([]
byte
(
"success"
))
}
source/server/go.mod
View file @
0794f28
...
...
@@ -5,6 +5,7 @@ go 1.15
require (
github.com/dgrijalva/jwt-go v3.2.0+incompatible
github.com/go-sql-driver/mysql v1.5.0
github.com/google/uuid v1.1.2
github.com/gorilla/mux v1.8.0
github.com/jmoiron/sqlx v1.2.0
golang.org/x/crypto v0.0.0-20201016220609-9e8e0b390897
...
...
source/server/go.sum
View file @
0794f28
...
...
@@ -4,6 +4,8 @@ github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZm
github.com/go-sql-driver/mysql v1.4.0/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w=
github.com/go-sql-driver/mysql v1.5.0 h1:ozyZYNQW3x3HtqT1jira07DN2PArx2v7/mN66gGcHOs=
github.com/go-sql-driver/mysql v1.5.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg=
github.com/google/uuid v1.1.2 h1:EVhdT+1Kseyi1/pUmXKaFxYsDNy9RQYkMWRH68J/W7Y=
github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/gorilla/mux v1.8.0 h1:i40aqfkR1h2SlN9hojwV5ZA91wcXFOvkdNIeFDP5koI=
github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So=
github.com/jmoiron/sqlx v1.2.0 h1:41Ip0zITnmWNR/vHV+S4m+VoUivnWY5E4OJfLZjCJMA=
...
...
Please
register
or
login
to post a comment