MCPcopy Create free account
hub / github.com/imroc/req / SetFileBytes

Method SetFileBytes

request.go:279–288  ·  view source on GitHub ↗

SetFileBytes set up a multipart form with given []byte to upload.

(paramName, filename string, content []byte)

Source from the content-addressed store, hash-verified

277
278// SetFileBytes set up a multipart form with given []byte to upload.
279func (r *Request) SetFileBytes(paramName, filename string, content []byte) *Request {
280 r.SetFileUpload(FileUpload{
281 ParamName: paramName,
282 FileName: filename,
283 GetFileContent: func() (io.ReadCloser, error) {
284 return io.NopCloser(bytes.NewReader(content)), nil
285 },
286 })
287 return r
288}
289
290// SetFiles set up a multipart form from a map to upload, which
291// key is the parameter name, and value is the file path.

Callers 2

SetFileBytesFunction · 0.80
TestSetFileBytesFunction · 0.80

Calls 1

SetFileUploadMethod · 0.95

Tested by 1

TestSetFileBytesFunction · 0.64