mirror of
https://github.com/balzack/databag.git
synced 2025-02-12 03:29:16 +00:00
support byte ranges for field data as well
This commit is contained in:
parent
06957fdcd7
commit
b53115fb52
@ -1,6 +1,8 @@
|
||||
package databag
|
||||
|
||||
import (
|
||||
"time"
|
||||
"bytes"
|
||||
"errors"
|
||||
"net/http"
|
||||
"gorm.io/gorm"
|
||||
@ -42,7 +44,7 @@ func GetCardProfileImage(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
w.Header().Set("Content-Type", http.DetectContentType(data))
|
||||
w.Write(data);
|
||||
// response with content
|
||||
http.ServeContent(w, r, "image", time.Unix(slot.Card.Updated, 0), bytes.NewReader(data))
|
||||
}
|
||||
|
||||
|
@ -10,8 +10,6 @@ import (
|
||||
|
||||
func GetChannelTopicAsset(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
PrintMsg(r)
|
||||
|
||||
// scan parameters
|
||||
params := mux.Vars(r)
|
||||
topicId := params["topicId"]
|
||||
|
@ -1,6 +1,8 @@
|
||||
package databag
|
||||
|
||||
import (
|
||||
"time"
|
||||
"bytes"
|
||||
"errors"
|
||||
"net/http"
|
||||
"encoding/base64"
|
||||
@ -26,8 +28,8 @@ func GetProfileImage(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
w.Header().Set("Content-Type", http.DetectContentType(data))
|
||||
w.Write(data);
|
||||
// response with content
|
||||
http.ServeContent(w, r, "image", time.Unix(account.Updated, 0), bytes.NewReader(data))
|
||||
}
|
||||
|
||||
|
||||
|
@ -66,6 +66,7 @@ type Account struct {
|
||||
ChannelRevision int64 `gorm:"not null;default:1"`
|
||||
CardRevision int64 `gorm:"not null;default:1"`
|
||||
Created int64 `gorm:"autoCreateTime"`
|
||||
Updated int64 `gorm:"autoUpdateTime"`
|
||||
Disabled bool `gorm:"not null;default:false"`
|
||||
AccountDetail AccountDetail
|
||||
Apps []App
|
||||
|
@ -140,7 +140,7 @@ func TestAttributeShare(t *testing.T) {
|
||||
param["articleId"] = article.Id
|
||||
param["field"] = "nested.image"
|
||||
aData, aType, aErr := ApiTestData(GetArticleSubjectField, "GET", "/attributes/articles/{articleId}/subject/{field}",
|
||||
¶m, nil, APP_TOKENAPP, set.A.Token)
|
||||
¶m, nil, APP_TOKENAPP, set.A.Token, 0, 0)
|
||||
assert.NoError(t, aErr)
|
||||
assert.Equal(t, "image/png", aType["Content-Type"][0])
|
||||
img, _ = base64.StdEncoding.DecodeString(image)
|
||||
@ -150,7 +150,7 @@ func TestAttributeShare(t *testing.T) {
|
||||
param["articleId"] = article.Id
|
||||
param["field"] = "nested.image"
|
||||
cData, cType, cErr := ApiTestData(GetArticleSubjectField, "GET", "/attributes/articles/{articleId}/subject/{field}",
|
||||
¶m, nil, APP_TOKENCONTACT, set.C.A.Token)
|
||||
¶m, nil, APP_TOKENCONTACT, set.C.A.Token, 0, 0)
|
||||
assert.NoError(t, cErr)
|
||||
assert.Equal(t, "image/png", cType["Content-Type"][0])
|
||||
img, _ = base64.StdEncoding.DecodeString(image)
|
||||
|
@ -41,7 +41,7 @@ func TestContactSync(t *testing.T) {
|
||||
¶m, &msg, APP_TOKENAPP, set.B.Token, &card, nil))
|
||||
assert.True(t, card.Data.CardProfile.ImageSet)
|
||||
data, hdr, res = ApiTestData(GetCardProfileImage, "GET", "/contact/cards/{cardId}/profile/image",
|
||||
¶m, &data, APP_TOKENAPP, set.B.Token)
|
||||
¶m, &data, APP_TOKENAPP, set.B.Token, 0, 0)
|
||||
assert.NoError(t, res)
|
||||
|
||||
// compare retrieved image
|
||||
|
@ -103,7 +103,7 @@ func TestProfileUpdate(t *testing.T) {
|
||||
|
||||
// retrieve profile image
|
||||
data, hdr, err = ApiTestData(GetProfileImage, "GET", "/profile/image", nil, nil,
|
||||
APP_TOKENAPP, set.A.Token)
|
||||
APP_TOKENAPP, set.A.Token, 0, 0)
|
||||
assert.NoError(t, err)
|
||||
|
||||
// compare retrieved image
|
||||
|
Loading…
Reference in New Issue
Block a user