...

Source file src/github.com/99designs/gqlgen/graphql/upload.go

Documentation: github.com/99designs/gqlgen/graphql

     1  package graphql
     2  
     3  import (
     4  	"fmt"
     5  	"io"
     6  )
     7  
     8  type Upload struct {
     9  	File        io.ReadSeeker
    10  	Filename    string
    11  	Size        int64
    12  	ContentType string
    13  }
    14  
    15  func MarshalUpload(f Upload) Marshaler {
    16  	return WriterFunc(func(w io.Writer) {
    17  		io.Copy(w, f.File)
    18  	})
    19  }
    20  
    21  func UnmarshalUpload(v interface{}) (Upload, error) {
    22  	upload, ok := v.(Upload)
    23  	if !ok {
    24  		return Upload{}, fmt.Errorf("%T is not an Upload", v)
    25  	}
    26  	return upload, nil
    27  }
    28  

View as plain text