streaming d'un fichier

This commit is contained in:
venture
2026-09-25 15:34:28 +02:00
parent 9e8b01b135
commit b869f70922
23 changed files with 856 additions and 1 deletions
+27
View File
@@ -107,6 +107,33 @@ func FilesGetOcr(c *gin.Context) {
api.OK(c, dto)
}
// FilesContent streame les octets physiques d'un fichier visible (viewer+,
// own ou shared) : GET /files/:id/content. Réponse binaire (Content-Type du
// fichier, Content-Disposition inline) — jamais d'enveloppe {data}. Supporte
// Range via http.ServeContent (Gin c.File). Sans bytes serveur (ressource
// metadata-only jamais uploadée) → 404 NOT_FOUND, comme invisible (pas
// d'énumération). V1 streaming : le client ne persiste rien.
func FilesContent(c *gin.Context) {
if Store == nil {
api.Error(c, http.StatusServiceUnavailable, "SERVICE_UNAVAILABLE", "backend not initialized")
return
}
userID := c.GetString(UserIDKey)
id := c.Param("id")
if !deviceIDPattern.MatchString(id) {
api.Error(c, http.StatusNotFound, "NOT_FOUND", "file not found")
return
}
info, err := Store.OpenContent(userID, id)
if err != nil {
writeError(c, err)
return
}
c.Header("Content-Type", info.MimeType)
c.Header("Content-Disposition", "inline; filename=\""+info.Name+"\"")
c.File(info.Path)
}
func FilesDelete(c *gin.Context) {
if Store == nil {
api.Error(c, http.StatusServiceUnavailable, "SERVICE_UNAVAILABLE", "backend not initialized")