This commit is contained in:
withchao 2023-03-29 11:17:16 +08:00
parent 5edcb9908d
commit 73747e0b38
4 changed files with 37 additions and 22 deletions

View File

@ -81,13 +81,14 @@ func (o *Third) GetURL(c *gin.Context) {
c.String(http.StatusBadRequest, fmt.Sprintf("expires is invalid: %s", err.Error()))
return
}
attachment, _ := strconv.ParseBool(c.Query("attachment"))
client, err := o.client()
if err != nil {
c.String(http.StatusInternalServerError, err.Error())
return
}
c.Set(constant.OperationID, operationID)
resp, err := client.GetUrl(mcontext.SetOperationID(c, operationID), &third.GetUrlReq{Name: name, Expires: expires})
resp, err := client.GetUrl(mcontext.SetOperationID(c, operationID), &third.GetUrlReq{Name: name, Expires: expires, Attachment: attachment})
if err != nil {
if errs.ErrArgs.Is(err) {
c.String(http.StatusBadRequest, err.Error())

View File

@ -379,7 +379,10 @@ func (c *s3Database) GetUrl(ctx context.Context, req *third.GetUrlReq) (*third.G
if err != nil {
return nil, err
}
opt := obj.HeaderOption{Filename: info.Name, ContentType: info.ContentType}
opt := obj.HeaderOption{ContentType: info.ContentType}
if req.Attachment {
opt.Filename = info.Name
}
u, err := c.obj.PresignedGetURL(ctx, hash.Bucket, hash.Name, time.Duration(req.Expires)*time.Millisecond, &opt)
if err != nil {
return nil, err

View File

@ -282,8 +282,9 @@ type GetUrlReq struct {
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name"` // 文件名
Expires int64 `protobuf:"varint,2,opt,name=expires,proto3" json:"expires"` // url有效时间
Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name"` // 文件名
Expires int64 `protobuf:"varint,2,opt,name=expires,proto3" json:"expires"` // url有效时间
Attachment bool `protobuf:"varint,3,opt,name=attachment,proto3" json:"attachment"` // 是否是附件
}
func (x *GetUrlReq) Reset() {
@ -332,6 +333,13 @@ func (x *GetUrlReq) GetExpires() int64 {
return 0
}
func (x *GetUrlReq) GetAttachment() bool {
if x != nil {
return x.Attachment
}
return false
}
type GetUrlResp struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
@ -597,7 +605,7 @@ type GetSignalInvitationInfoReq struct {
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
ClientMsgID string `protobuf:"bytes,1,opt,name=ClientMsgID,proto3" json:"ClientMsgID"`
ClientMsgID string `protobuf:"bytes,1,opt,name=clientMsgID,proto3" json:"clientMsgID"`
}
func (x *GetSignalInvitationInfoReq) Reset() {
@ -801,8 +809,8 @@ type FcmUpdateTokenReq struct {
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
PlatformID int32 `protobuf:"varint,1,opt,name=PlatformID,proto3" json:"PlatformID"`
FcmToken string `protobuf:"bytes,2,opt,name=FcmToken,proto3" json:"FcmToken"`
PlatformID int32 `protobuf:"varint,1,opt,name=platformID,proto3" json:"platformID"`
FcmToken string `protobuf:"bytes,2,opt,name=fcmToken,proto3" json:"fcmToken"`
Account string `protobuf:"bytes,3,opt,name=account,proto3" json:"account"`
ExpireTime int64 `protobuf:"varint,4,opt,name=expireTime,proto3" json:"expireTime"`
}
@ -911,7 +919,7 @@ type SetAppBadgeReq struct {
unknownFields protoimpl.UnknownFields
UserID string `protobuf:"bytes,1,opt,name=userID,proto3" json:"userID"`
AppUnreadCount int32 `protobuf:"varint,2,opt,name=AppUnreadCount,proto3" json:"AppUnreadCount"`
AppUnreadCount int32 `protobuf:"varint,2,opt,name=appUnreadCount,proto3" json:"appUnreadCount"`
}
func (x *SetAppBadgeReq) Reset() {
@ -1027,11 +1035,13 @@ var file_third_third_proto_rawDesc = []byte{
0x71, 0x12, 0x14, 0x0a, 0x05, 0x70, 0x75, 0x74, 0x49, 0x44, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09,
0x52, 0x05, 0x70, 0x75, 0x74, 0x49, 0x44, 0x22, 0x22, 0x0a, 0x0e, 0x43, 0x6f, 0x6e, 0x66, 0x69,
0x72, 0x6d, 0x50, 0x75, 0x74, 0x52, 0x65, 0x73, 0x70, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x72, 0x6c,
0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x75, 0x72, 0x6c, 0x22, 0x39, 0x0a, 0x09, 0x47,
0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x75, 0x72, 0x6c, 0x22, 0x59, 0x0a, 0x09, 0x47,
0x65, 0x74, 0x55, 0x72, 0x6c, 0x52, 0x65, 0x71, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65,
0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x18, 0x0a, 0x07,
0x65, 0x78, 0x70, 0x69, 0x72, 0x65, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x07, 0x65,
0x78, 0x70, 0x69, 0x72, 0x65, 0x73, 0x22, 0x46, 0x0a, 0x0a, 0x47, 0x65, 0x74, 0x55, 0x72, 0x6c,
0x78, 0x70, 0x69, 0x72, 0x65, 0x73, 0x12, 0x1e, 0x0a, 0x0a, 0x61, 0x74, 0x74, 0x61, 0x63, 0x68,
0x6d, 0x65, 0x6e, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0a, 0x61, 0x74, 0x74, 0x61,
0x63, 0x68, 0x6d, 0x65, 0x6e, 0x74, 0x22, 0x46, 0x0a, 0x0a, 0x47, 0x65, 0x74, 0x55, 0x72, 0x6c,
0x52, 0x65, 0x73, 0x70, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x72, 0x6c, 0x18, 0x01, 0x20, 0x01, 0x28,
0x09, 0x52, 0x03, 0x75, 0x72, 0x6c, 0x12, 0x12, 0x0a, 0x04, 0x73, 0x69, 0x7a, 0x65, 0x18, 0x02,
0x20, 0x01, 0x28, 0x03, 0x52, 0x04, 0x73, 0x69, 0x7a, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x68, 0x61,
@ -1058,9 +1068,9 @@ var file_third_third_proto_rawDesc = []byte{
0x72, 0x64, 0x2e, 0x47, 0x65, 0x74, 0x50, 0x75, 0x74, 0x46, 0x72, 0x61, 0x67, 0x6d, 0x65, 0x6e,
0x74, 0x52, 0x09, 0x66, 0x72, 0x61, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x22, 0x3e, 0x0a, 0x1a,
0x47, 0x65, 0x74, 0x53, 0x69, 0x67, 0x6e, 0x61, 0x6c, 0x49, 0x6e, 0x76, 0x69, 0x74, 0x61, 0x74,
0x69, 0x6f, 0x6e, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x71, 0x12, 0x20, 0x0a, 0x0b, 0x43, 0x6c,
0x69, 0x6f, 0x6e, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x71, 0x12, 0x20, 0x0a, 0x0b, 0x63, 0x6c,
0x69, 0x65, 0x6e, 0x74, 0x4d, 0x73, 0x67, 0x49, 0x44, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52,
0x0b, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x4d, 0x73, 0x67, 0x49, 0x44, 0x22, 0xb8, 0x01, 0x0a,
0x0b, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x4d, 0x73, 0x67, 0x49, 0x44, 0x22, 0xb8, 0x01, 0x0a,
0x1b, 0x47, 0x65, 0x74, 0x53, 0x69, 0x67, 0x6e, 0x61, 0x6c, 0x49, 0x6e, 0x76, 0x69, 0x74, 0x61,
0x74, 0x69, 0x6f, 0x6e, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x73, 0x70, 0x12, 0x4a, 0x0a, 0x0e,
0x69, 0x6e, 0x76, 0x69, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x49, 0x6e, 0x66, 0x6f, 0x18, 0x01,
@ -1090,10 +1100,10 @@ var file_third_third_proto_rawDesc = []byte{
0x75, 0x73, 0x68, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x0f, 0x6f, 0x66, 0x66, 0x6c, 0x69, 0x6e, 0x65,
0x50, 0x75, 0x73, 0x68, 0x49, 0x6e, 0x66, 0x6f, 0x22, 0x89, 0x01, 0x0a, 0x11, 0x46, 0x63, 0x6d,
0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x52, 0x65, 0x71, 0x12, 0x1e,
0x0a, 0x0a, 0x50, 0x6c, 0x61, 0x74, 0x66, 0x6f, 0x72, 0x6d, 0x49, 0x44, 0x18, 0x01, 0x20, 0x01,
0x28, 0x05, 0x52, 0x0a, 0x50, 0x6c, 0x61, 0x74, 0x66, 0x6f, 0x72, 0x6d, 0x49, 0x44, 0x12, 0x1a,
0x0a, 0x08, 0x46, 0x63, 0x6d, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09,
0x52, 0x08, 0x46, 0x63, 0x6d, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x12, 0x18, 0x0a, 0x07, 0x61, 0x63,
0x0a, 0x0a, 0x70, 0x6c, 0x61, 0x74, 0x66, 0x6f, 0x72, 0x6d, 0x49, 0x44, 0x18, 0x01, 0x20, 0x01,
0x28, 0x05, 0x52, 0x0a, 0x70, 0x6c, 0x61, 0x74, 0x66, 0x6f, 0x72, 0x6d, 0x49, 0x44, 0x12, 0x1a,
0x0a, 0x08, 0x66, 0x63, 0x6d, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09,
0x52, 0x08, 0x66, 0x63, 0x6d, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x12, 0x18, 0x0a, 0x07, 0x61, 0x63,
0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x61, 0x63, 0x63,
0x6f, 0x75, 0x6e, 0x74, 0x12, 0x1e, 0x0a, 0x0a, 0x65, 0x78, 0x70, 0x69, 0x72, 0x65, 0x54, 0x69,
0x6d, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0a, 0x65, 0x78, 0x70, 0x69, 0x72, 0x65,
@ -1101,8 +1111,8 @@ var file_third_third_proto_rawDesc = []byte{
0x65, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x22, 0x50, 0x0a, 0x0e, 0x53, 0x65,
0x74, 0x41, 0x70, 0x70, 0x42, 0x61, 0x64, 0x67, 0x65, 0x52, 0x65, 0x71, 0x12, 0x16, 0x0a, 0x06,
0x75, 0x73, 0x65, 0x72, 0x49, 0x44, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x75, 0x73,
0x65, 0x72, 0x49, 0x44, 0x12, 0x26, 0x0a, 0x0e, 0x41, 0x70, 0x70, 0x55, 0x6e, 0x72, 0x65, 0x61,
0x64, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0e, 0x41, 0x70,
0x65, 0x72, 0x49, 0x44, 0x12, 0x26, 0x0a, 0x0e, 0x61, 0x70, 0x70, 0x55, 0x6e, 0x72, 0x65, 0x61,
0x64, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0e, 0x61, 0x70,
0x70, 0x55, 0x6e, 0x72, 0x65, 0x61, 0x64, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0x11, 0x0a, 0x0f,
0x53, 0x65, 0x74, 0x41, 0x70, 0x70, 0x42, 0x61, 0x64, 0x67, 0x65, 0x52, 0x65, 0x73, 0x70, 0x32,
0x87, 0x06, 0x0a, 0x05, 0x74, 0x68, 0x69, 0x72, 0x64, 0x12, 0x4d, 0x0a, 0x08, 0x41, 0x70, 0x70,

View File

@ -30,6 +30,7 @@ message ConfirmPutResp {
message GetUrlReq {
string name = 1; //
int64 expires = 2; // url有效时间
bool attachment = 3;//
}
message GetUrlResp {
@ -58,7 +59,7 @@ message GetPutResp {
}
message GetSignalInvitationInfoReq {
string ClientMsgID = 1;
string clientMsgID = 1;
}
message GetSignalInvitationInfoResp {
@ -76,8 +77,8 @@ message GetSignalInvitationInfoStartAppResp {
}
message FcmUpdateTokenReq {
int32 PlatformID = 1;
string FcmToken = 2;
int32 platformID = 1;
string fcmToken = 2;
string account = 3;
int64 expireTime = 4;
}
@ -87,7 +88,7 @@ message FcmUpdateTokenResp {
message SetAppBadgeReq {
string userID = 1;
int32 AppUnreadCount = 2;
int32 appUnreadCount = 2;
}
message SetAppBadgeResp {