-
Notifications
You must be signed in to change notification settings - Fork 1
/
filedata.go
71 lines (61 loc) · 1.64 KB
/
filedata.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
67
68
69
70
71
// A facebook graph api client in go.
// https://github.com/huandu/facebook/
//
// Copyright 2012 - 2015, Huan Du
// Licensed under the MIT license
// https://github.com/huandu/facebook/blob/master/LICENSE
package facebook
import (
"io"
)
// Binary data.
type binaryData struct {
Filename string // filename used in multipart form writer.
Source io.Reader // file data source.
ContentType string // content type of the data.
}
// Binary file.
type binaryFile struct {
Filename string // filename used in multipart form writer.
Path string // path to file. must be readable.
ContentType string // content type of the file.
}
// Creates new binary data holder.
func Data(filename string, source io.Reader) *binaryData {
return &binaryData{
Filename: filename,
Source: source,
}
}
// Creates new binary data holder with arbitrary content type.
func DataWithContentType(filename string, source io.Reader, contentType string) *binaryData {
return &binaryData{
Filename: filename,
Source: source,
ContentType: contentType,
}
}
// Creates a binary file holder.
func File(filename string) *binaryFile {
return &binaryFile{
Filename: filename,
}
}
// Creates a binary file holder and specific a different path for reading.
func FileAlias(filename, path string) *binaryFile {
return &binaryFile{
Filename: filename,
Path: path,
}
}
// Creates a new binary file holder with arbitrary content type.
func FileAliasWithContentType(filename, path, contentType string) *binaryFile {
if path == "" {
path = filename
}
return &binaryFile{
Filename: filename,
Path: path,
ContentType: contentType,
}
}