Fix logic with set attributes if not set from header

- if NOT set Filename from header - set from multipart/form
- if NOT set Timestamp from header and enabled by settings - set current timestamp

Signed-off-by: Evgeniy Kulikov <kim@nspcc.ru>
This commit is contained in:
Evgeniy Kulikov 2021-01-28 16:48:45 +03:00
parent ec70bfa4cc
commit 71999a796d
No known key found for this signature in database
GPG key ID: BF6AEE0A2A699BF2

View file

@ -116,7 +116,7 @@ func (a *app) upload(c *fasthttp.RequestCtx) {
}
// sets FileName attribute if it wasn't set from header
if _, ok := filtered[object.AttributeFileName]; ok {
if _, ok := filtered[object.AttributeFileName]; !ok {
filename := object.NewAttribute()
filename.SetKey(object.AttributeFileName)
filename.SetValue(name)
@ -125,7 +125,7 @@ func (a *app) upload(c *fasthttp.RequestCtx) {
}
// sets Timestamp attribute if it wasn't set from header and enabled by settings
if _, ok := filtered[object.AttributeTimestamp]; ok && a.enableDefaultTimestamp {
if _, ok := filtered[object.AttributeTimestamp]; !ok && a.enableDefaultTimestamp {
timestamp := object.NewAttribute()
timestamp.SetKey(object.AttributeTimestamp)
timestamp.SetValue(strconv.FormatInt(time.Now().Unix(), 10))