1
0
mirror of https://shylinux.com/x/icebergs synced 2025-04-25 17:18:05 +08:00
This commit is contained in:
root 2025-02-08 12:02:50 +08:00
parent 324cd9dc57
commit 297c299694
2 changed files with 14 additions and 2 deletions

View File

@ -40,7 +40,7 @@ func _spide_create(m *ice.Message, link, types, name, icons, token string) {
} }
func _spide_show(m *ice.Message, name string, arg ...string) { func _spide_show(m *ice.Message, name string, arg ...string) {
file := "" file := ""
action, arg := _spide_args(m, arg, SPIDE_RAW, SPIDE_DETAIL, SPIDE_MSG, SPIDE_SAVE, SPIDE_CACHE) action, arg := _spide_args(m, arg, SPIDE_RAW, SPIDE_DETAIL, SPIDE_MSG, SPIDE_SAVE, SPIDE_CACHE, SPIDE_STREAM)
kit.If(action == SPIDE_SAVE, func() { file, arg = arg[0], arg[1:] }) kit.If(action == SPIDE_SAVE, func() { file, arg = arg[0], arg[1:] })
msg := mdb.HashSelects(m.Spawn(), name) msg := mdb.HashSelects(m.Spawn(), name)
method, arg := _spide_args(m, arg, http.MethodGet, http.MethodPut, http.MethodPost, http.MethodDelete) method, arg := _spide_args(m, arg, http.MethodGet, http.MethodPut, http.MethodPost, http.MethodDelete)
@ -214,6 +214,17 @@ func _spide_save(m *ice.Message, action, file, uri string, res *http.Response) {
case SPIDE_CACHE: case SPIDE_CACHE:
m.Cmdy(CACHE, DOWNLOAD, res.Header.Get(html.ContentType), uri, kit.Dict(RESPONSE, res), m.OptionCB(SPIDE)) m.Cmdy(CACHE, DOWNLOAD, res.Header.Get(html.ContentType), uri, kit.Dict(RESPONSE, res), m.OptionCB(SPIDE))
m.Echo(m.Append(mdb.HASH)) m.Echo(m.Append(mdb.HASH))
case SPIDE_STREAM:
b := make([]byte, 1024)
cb := m.Optionv(SPIDE_STREAM).(func(string))
for {
n, e := res.Body.Read(b)
if e != nil {
break
}
m.Info("what %v", string(b[:n]))
cb(string(b[:n]))
}
default: default:
var data ice.Any var data ice.Any
if b, e := ioutil.ReadAll(res.Body); !m.WarnNotFound(e) { if b, e := ioutil.ReadAll(res.Body); !m.WarnNotFound(e) {
@ -232,6 +243,7 @@ const (
SPIDE_MSG = "msg" SPIDE_MSG = "msg"
SPIDE_SAVE = "save" SPIDE_SAVE = "save"
SPIDE_CACHE = "cache" SPIDE_CACHE = "cache"
SPIDE_STREAM = "stream"
SPIDE_BODY = "body" SPIDE_BODY = "body"
SPIDE_FORM = "form" SPIDE_FORM = "form"

View File

@ -46,7 +46,7 @@ func init() {
}}, }},
web.UPLOAD: {Hand: func(m *ice.Message, arg ...string) { web.UPLOAD: {Hand: func(m *ice.Message, arg ...string) {
up := kit.Simple(m.Optionv(ice.MSG_UPLOAD)) up := kit.Simple(m.Optionv(ice.MSG_UPLOAD))
m.Cmdy(web.CACHE, web.WATCH, m.Option(mdb.HASH), path.Join(m.Option(nfs.PATH), up[1])) m.Cmdy(web.CACHE, web.WATCH, up[0], path.Join(m.Option(nfs.PATH), up[1]))
}}, }},
mdb.RENAME: {Name: "rename name*", Hand: func(m *ice.Message, arg ...string) { mdb.RENAME: {Name: "rename name*", Hand: func(m *ice.Message, arg ...string) {
m.Cmdy(nfs.MOVE, path.Join(path.Dir(m.Option(nfs.PATH)), m.Option(mdb.NAME)), m.Option(nfs.PATH)) m.Cmdy(nfs.MOVE, path.Join(path.Dir(m.Option(nfs.PATH)), m.Option(mdb.NAME)), m.Option(nfs.PATH))