英文:
set graphql's max file upload size (golang)
问题
我用golang编写了一个服务器,可以使用multipart form上传文件。我想扩展最大上传大小。
在我使用的实现的文档网站上,我找到了以下信息:
-
uploadMaxSize
此选项指定用于解析请求体作为multipart/form-data的最大字节数。 -
uploadMaxMemory
此选项指定用于在内存中解析请求体作为multipart/form-data的最大字节数,其余部分存储在临时文件中。
(这里是链接:https://github.com/99designs/gqlgen/blob/master/docs/content/reference/file-upload.md#Configuration)
这个配置可以在哪里应用?
谢谢。
英文:
I wrote an server in golang which to which files can be uploaded using multipart form. I want to extend the maximum upload size.
On the documentation site of the implementation I'm using I found following:
-
uploadMaxSize
This option specifies the maximum number of bytes used to parse a request body as multipart/form-data. -
uploadMaxMemory
This option specifies the maximum number of bytes used to parse a request body as multipart/form-data in memory, with the remainder stored on disk in temporary files.
(here: https://github.com/99designs/gqlgen/blob/master/docs/content/reference/file-upload.md#Configuration)
Where can this configuration be applied?
Thanks
答案1
得分: 3
你可以在你的GraphQL
处理程序中应用这些配置选项,如下所示:
var mb int64 = 1 << 20
uploadMaxMemory := handler.UploadMaxMemory(32 * mb)
uploadMaxSize := handler.UploadMaxSize(50 * mb)
http.Handle("/query", handler.GraphQL(exec, uploadMaxMemory, uploadMaxSize))
英文:
You can apply these configuration options in your GraphQL
handler, like:
var mb int64 = 1 << 20
uploadMaxMemory := handler.UploadMaxMemory(32 * mb)
uploadMaxSize := handler.UploadMaxSize(50 * mb)
http.Handle("/query", handler.GraphQL(exec, uploadMaxMemory, uploadMaxSize))
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论