-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig.go
More file actions
148 lines (102 loc) · 3.16 KB
/
config.go
File metadata and controls
148 lines (102 loc) · 3.16 KB
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
// Package storage provides content storage and functions.
package storage
import (
"net/http"
"time"
)
const storageVersion = "1"
// Storage represents content uploaded by users.
type Storage struct {
// Uploaded files
Files map[string]*File `json:"files,omitempty"`
// Posted text messages
Messages map[int]*Message `json:"messages,omitempty"`
// Shared edit content
WallContent string `json:"wallContent,omitempty"`
// Storage content total sizes
Sizes `json:"storageSizes,omitempty"`
}
// File represents a user-uploaded file.
type File struct {
// Unique identifier
Id string `json:"id,omitempty"`
// Provided filename
Name string `json:"name,omitempty"`
// Contents of upload
Data []byte `json:"data,omitempty"`
// Content hash sum
Sum string `json:"sum,omitempty"`
// Downloads information
Downloads `json:"downloads,omitempty"`
// Number of bytes
Bytes int `json:"bytes,omitempty"`
// File length (for Content-Length header)
Length string `json:"length,omitempty"`
// File size (formatted string)
Size string `json:"size,omitempty"`
// File type (based on name extension)
Type string `json:"type,omitempty"`
// Uploader information
Owner `json:"owner,omitempty"`
// Timing information
Time `json:"time,omitempty"`
}
// Message represents a user-submitted text message.
type Message struct {
// Message count/order
Count int `json:"count,omitempty"`
// Message content
Data string `json:"data,omitempty"`
// Owner information
Owner `json:"owner,omitempty"`
// Timing information
Time `json:"time,omitempty"`
}
// Owner represents metadata about a user.
type Owner struct {
// IP address with port
Address string `json:"address,omitempty"`
// Masked IP address
Mask string `json:"mask,omitempty"`
// User Agent header
Agent string `json:"agent,omitempty"`
// Full HTTP headers
Headers http.Header `json:"headers,omitempty"`
}
// Time represents user content time metadata.
type Time struct {
// Duration of file lifetime
Duration time.Duration `json:"duration,omitempty"`
// Formatted duration of file lifetime
Allow string `json:"allow,omitempty"`
// Formatted duration until expiration
Remain string `json:"remain,omitempty"`
// Absolute upload datetime
Upload time.Time `json:"upload,omitempty"`
}
// Downloads represents user content downloads metadata.
type Downloads struct {
// Number of allowed downloads
Allow int `json:"allow,omitempty"`
// Remaining number of downloads to expiration
Remain int `json:"remain,omitempty"`
// Total number of downloads
Total int `json:"total,omitempty"`
}
// Sizes represents Storage content sizes.
type Sizes struct {
// Number of characters in all Messages
CharsMessages int `json:"charsMessages,omitempty"`
// Number of characters in Wall content
CharsWall int `json:"charsWall,omitempty"`
// Number of lines in Wall content
LinesWall int `json:"linesWall,omitempty"`
// Number of Files
NumFiles int `json:"numFiles,omitempty"`
// Number of Messages
NumMessages int `json:"numMessages,omitempty"`
// Total size of all Files
SizeFiles int `json:"sizeFiles,omitempty"`
// Formatted total size of all Files
SizeFilesFmt string `json:"sizeFilesFmt,omitempty"`
}