Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the custom handling method after the file upload / program panic crash of the Golang GinWeb framework

2025-01-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article mainly explains the "Golang GinWeb framework file upload / program panic crash after the custom processing is what", the article explains the content is simple and clear, easy to learn and understand, the following please follow the editor's ideas slowly in-depth, together to study and learn "Golang GinWeb framework file upload / program panic crash after the custom processing is what" it!

Upload files

Single file upload

Note: the file name must be safe and reliable. You need to remove the path information and keep the file name.

Package main import ("fmt"github.com/gin-gonic/gin"log"net/http"os") func main () {router: = gin.Default () / / Set a lower memory limit for multipart forms (default is 32 MiB) / / sets the maximum memory limit of the request form. The default is 30MB / / internal call to the ParseMultipartForm method of the http request, which requires passing in a byte To fetch the data of the MultipartForm field First parse the Form using the ParseMultipartForm () method, which reads all the data, but you need to specify the maximum number of bytes to be saved in memory, and the remaining bytes are saved in the temporary disk file maxMultipartMemory: = int64 (8

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report