Commit dfc0889a authored by Steven's avatar Steven

chore: tweak package name

parent da535c8d
// Package getter is using to get resources from url.
// Package httpgetter is using to get resources from url.
// * Get metadata for website;
// * Get image blob to avoid CORS;
package getter
package httpgetter
package getter
package httpgetter
import (
"errors"
......
package getter
package httpgetter
import (
"mime"
......
......@@ -15,10 +15,6 @@ import (
storepb "github.com/usememos/memos/proto/gen/store"
)
// presignLifetimeSecs is the lifetime of a presigned URL in seconds.
// The presigned URL is valid for 7 days.
const presignLifetimeSecs = 7 * 24 * 60 * 60
type Client struct {
Client *s3.Client
Bucket *string
......@@ -74,7 +70,7 @@ func (c *Client) PresignGetObject(ctx context.Context, key string) (string, erro
Bucket: aws.String(*c.Bucket),
Key: aws.String(key),
}, func(opts *s3.PresignOptions) {
opts.Expires = time.Duration(presignLifetimeSecs * int64(time.Second))
opts.Expires = time.Duration(7 * 24 * time.Hour)
})
if err != nil {
return "", errors.Wrap(err, "failed to presign put object")
......
......@@ -9,7 +9,7 @@ import (
"github.com/yourselfhosted/gomark/parser/tokenizer"
"github.com/yourselfhosted/gomark/restore"
getter "github.com/usememos/memos/plugin/http-getter"
"github.com/usememos/memos/plugin/httpgetter"
v1pb "github.com/usememos/memos/proto/gen/api/v1"
)
......@@ -33,7 +33,7 @@ func (*APIV1Service) RestoreMarkdown(_ context.Context, request *v1pb.RestoreMar
}
func (*APIV1Service) GetLinkMetadata(_ context.Context, request *v1pb.GetLinkMetadataRequest) (*v1pb.LinkMetadata, error) {
htmlMeta, err := getter.GetHTMLMeta(request.Link)
htmlMeta, err := httpgetter.GetHTMLMeta(request.Link)
if err != nil {
return nil, err
}
......
......@@ -53,8 +53,9 @@ func (p *S3ObjectPresigner) CheckAndPresign(ctx context.Context) {
}
if s3ObjectPayload.LastPresignedTime != nil {
// Skip if the presigned URL is still valid.
if time.Now().Before(s3ObjectPayload.LastPresignedTime.AsTime().Add(24 * time.Hour)) {
// Skip if the presigned URL is still valid for the next 6 days.
// The default expiration time is 7 days.
if time.Now().Before(s3ObjectPayload.LastPresignedTime.AsTime().Add(6 * 24 * time.Hour)) {
continue
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment