1// A facebook graph api client in go.
2// https://github.com/huandu/facebook/
3//
4// Copyright 2012, Huan Du
5// Licensed under the MIT license
6// https://github.com/huandu/facebook/blob/master/LICENSE
7
8package facebook
9
10import (
11	"io"
12)
13
14// BinaryData represents binary data from a given source.
15type BinaryData struct {
16	Filename    string    // filename used in multipart form writer.
17	Source      io.Reader // file data source.
18	ContentType string    // content type of the data.
19}
20
21// BinaryFile represents a file on disk.
22type BinaryFile struct {
23	Filename    string // filename used in multipart form writer.
24	Path        string // path to file. must be readable.
25	ContentType string // content type of the file.
26}
27
28// Data creates new binary data holder.
29func Data(filename string, source io.Reader) *BinaryData {
30	return &BinaryData{
31		Filename: filename,
32		Source:   source,
33	}
34}
35
36// DataWithContentType creates new binary data holder with arbitrary content type.
37func DataWithContentType(filename string, source io.Reader, contentType string) *BinaryData {
38	return &BinaryData{
39		Filename:    filename,
40		Source:      source,
41		ContentType: contentType,
42	}
43}
44
45// File creates a binary file holder.
46func File(filename string) *BinaryFile {
47	return &BinaryFile{
48		Filename: filename,
49	}
50}
51
52// FileAlias creates a binary file holder and specific a different path for reading.
53func FileAlias(filename, path string) *BinaryFile {
54	return &BinaryFile{
55		Filename: filename,
56		Path:     path,
57	}
58}
59
60// FileAliasWithContentType creates a new binary file holder with arbitrary content type.
61func FileAliasWithContentType(filename, path, contentType string) *BinaryFile {
62	if path == "" {
63		path = filename
64	}
65
66	return &BinaryFile{
67		Filename:    filename,
68		Path:        path,
69		ContentType: contentType,
70	}
71}
72