forked from 0xDkd/auxpi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathOoxx.go
66 lines (54 loc) · 1.47 KB
/
Ooxx.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
// Copyright (c) 2019 aimerforreimu. All Rights Reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//
// GNU GENERAL PUBLIC LICENSE
// Version 3, 29 June 2007
//
// Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
// Everyone is permitted to copy and distribute verbatim copies
// of this license document, but changing it is not allowed.
//
// repo: https://github.com/aimerforreimu/auxpi
package server
import (
"encoding/json"
"github.com/auxpi/auxpiAll"
"github.com/auxpi/tools"
)
type OOXX struct {
FileLimit []string
MaxSize int
}
func (s *OOXX) Upload(image *ImageParam) (ImageReturn, error) {
url := "https://ooxx.ooo/upload"
file := &auxpi.FormFile{
Name: image.Name,
Key: "files[]",
Value: *image.Content,
Type: image.Type,
}
var header map[string]string
data := tools.FormPost(file, url, header)
var m = []string{}
json.Unmarshal([]byte(data), &m)
return ImageReturn{
Url: "https://i.ooxx.ooo" + m[0],
ID: 16,
}, nil
}
func (s *OOXX) UploadToOOXX(img []byte, imgInfo string, imgType string) string {
url := "https://ooxx.ooo/upload"
name := tools.GetFileNameByMimeType(imgInfo)
file := &auxpi.FormFile{
Name: name,
Key: "files[]",
Value: img,
Type: imgType,
}
var header map[string]string
data := tools.FormPost(file, url, header)
var m = []string{}
json.Unmarshal([]byte(data), &m)
return "https://i.ooxx.ooo" + m[0]
}