Enhance server configuration for large file uploads and improve token handling. Increase request body size limit in the server to 20 GB, update registration token expiration logic to support infinite expiration, and adjust database schema to accommodate larger file sizes. Add detailed logging for file upload processes and error handling improvements.
This commit is contained in:
@@ -25,8 +25,13 @@ func (s *Server) handleGenerateRegistrationToken(w http.ResponseWriter, r *http.
|
||||
ExpiresInHours int `json:"expires_in_hours,omitempty"`
|
||||
}
|
||||
if r.Body != nil && r.ContentLength > 0 {
|
||||
if err := json.NewDecoder(r.Body).Decode(&req); err == nil && req.ExpiresInHours > 0 {
|
||||
expiresIn = time.Duration(req.ExpiresInHours) * time.Hour
|
||||
if err := json.NewDecoder(r.Body).Decode(&req); err == nil {
|
||||
if req.ExpiresInHours == 0 {
|
||||
// 0 hours means infinite expiration
|
||||
expiresIn = 0
|
||||
} else if req.ExpiresInHours > 0 {
|
||||
expiresIn = time.Duration(req.ExpiresInHours) * time.Hour
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,11 +41,17 @@ func (s *Server) handleGenerateRegistrationToken(w http.ResponseWriter, r *http.
|
||||
return
|
||||
}
|
||||
|
||||
s.respondJSON(w, http.StatusCreated, map[string]interface{}{
|
||||
"token": token,
|
||||
"expires_in": expiresIn.String(),
|
||||
"expires_at": time.Now().Add(expiresIn),
|
||||
})
|
||||
response := map[string]interface{}{
|
||||
"token": token,
|
||||
}
|
||||
if expiresIn == 0 {
|
||||
response["expires_in"] = "infinite"
|
||||
response["expires_at"] = nil
|
||||
} else {
|
||||
response["expires_in"] = expiresIn.String()
|
||||
response["expires_at"] = time.Now().Add(expiresIn)
|
||||
}
|
||||
s.respondJSON(w, http.StatusCreated, response)
|
||||
}
|
||||
|
||||
// handleListRegistrationTokens lists all registration tokens
|
||||
|
||||
Reference in New Issue
Block a user