mediaapi/writers/download: Set more metadata fields for remote files

This commit is contained in:
Robert Swain 2017-05-09 20:58:44 +02:00
parent 5bb5a28366
commit c7c3a36e1b

View file

@ -230,6 +230,11 @@ func Download(w http.ResponseWriter, req *http.Request, origin types.ServerName,
} }
r.MediaMetadata.ContentLength = types.ContentLength(contentLength) r.MediaMetadata.ContentLength = types.ContentLength(contentLength)
r.MediaMetadata.ContentType = types.ContentType(resp.Header.Get("Content-Type"))
r.MediaMetadata.ContentDisposition = types.ContentDisposition(resp.Header.Get("Content-Disposition"))
// FIXME: parse from Content-Disposition header if possible, else fall back
//r.MediaMetadata.UploadName = types.Filename()
logger.WithFields(log.Fields{ logger.WithFields(log.Fields{
"MediaID": r.MediaMetadata.MediaID, "MediaID": r.MediaMetadata.MediaID,
"Origin": r.MediaMetadata.Origin, "Origin": r.MediaMetadata.Origin,
@ -355,6 +360,9 @@ func Download(w http.ResponseWriter, req *http.Request, origin types.ServerName,
// Note: After this point we have responded to the client's request and are just dealing with local caching. // Note: After this point we have responded to the client's request and are just dealing with local caching.
// As we have responded with 200 OK, any errors are ineffectual to the client request and so we just log and return. // As we have responded with 200 OK, any errors are ineffectual to the client request and so we just log and return.
r.MediaMetadata.ContentLength = types.ContentLength(bytesWritten)
r.MediaMetadata.UserID = types.MatrixUserID("@unknown:" + string(r.MediaMetadata.Origin))
logger.WithFields(log.Fields{ logger.WithFields(log.Fields{
"MediaID": r.MediaMetadata.MediaID, "MediaID": r.MediaMetadata.MediaID,
"Origin": r.MediaMetadata.Origin, "Origin": r.MediaMetadata.Origin,