blob: 22d61031495322761db4187c998506ac09ed609b (
plain) (
blame)
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
|
package graphql
import (
"fmt"
"io"
)
type Upload struct {
File io.Reader
Filename string
Size int64
}
func MarshalUpload(f Upload) Marshaler {
return WriterFunc(func(w io.Writer) {
io.Copy(w, f.File)
})
}
func UnmarshalUpload(v interface{}) (Upload, error) {
upload, ok := v.(Upload)
if !ok {
return Upload{}, fmt.Errorf("%T is not an Upload", v)
}
return upload, nil
}
|