Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
张磊
/
FileStorageBeego
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
6ce02f1d
authored
2013-04-16 18:20:55 +0800
by
astaxie
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
add SaveToFile & docs
1 parent
e8653255
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
0 deletions
controller.go
docs/zh/Quickstart.md
controller.go
View file @
6ce02f1
...
...
@@ -6,10 +6,12 @@ import (
"encoding/xml"
"github.com/astaxie/beego/session"
"html/template"
"io"
"io/ioutil"
"mime/multipart"
"net/http"
"net/url"
"os"
"path"
"strconv"
"strings"
...
...
@@ -197,6 +199,21 @@ func (c *Controller) GetFile(key string) (multipart.File, *multipart.FileHeader,
return
c
.
Ctx
.
Request
.
FormFile
(
key
)
}
func
(
c
*
Controller
)
SaveToFile
(
fromfile
,
tofile
string
)
error
{
file
,
_
,
err
:=
c
.
Ctx
.
Request
.
FormFile
(
fromfile
)
if
err
!=
nil
{
return
err
}
defer
file
.
Close
()
f
,
err
:=
os
.
OpenFile
(
tofile
,
os
.
O_WRONLY
|
os
.
O_CREATE
|
os
.
O_TRUNC
,
0666
)
if
err
!=
nil
{
return
err
}
defer
f
.
Close
()
io
.
Copy
(
f
,
file
)
return
nil
}
func
(
c
*
Controller
)
StartSession
()
(
sess
session
.
SessionStore
)
{
sess
=
GlobalSessions
.
SessionStart
(
c
.
Ctx
.
ResponseWriter
,
c
.
Ctx
.
Request
)
return
...
...
docs/zh/Quickstart.md
View file @
6ce02f1
This diff is collapsed.
Click to expand it.
Write
Preview
Styling with
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment