-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathutils.go
40 lines (32 loc) · 990 Bytes
/
utils.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package lambda_go_sdk
import (
"encoding/json"
"errors"
"fmt"
)
func serializeInputProps(inputProps interface{}, region string, inputType string,
userSpecifiedBucketName string) (*PayloadData, error) {
payload, err := json.Marshal(inputProps)
if inputProps == nil {
return &PayloadData{
Payload: "{}",
Type: "payload",
}, nil
}
if err != nil {
return nil, errors.New("error serializing inputProps. Check it has no circular references or reduce the size if the object is big")
}
// Set maximum inline payload size based on input type
maxInlinePayloadSize := 200000
if inputType == "still" {
maxInlinePayloadSize = 5000000
}
// Check if payload size is within the limit
if len(payload) > maxInlinePayloadSize {
return nil, fmt.Errorf("warning: inputProps are over %dKB (%dKB) in size. This is not currently supported", maxInlinePayloadSize/1000, len(payload)/1024)
}
return &PayloadData{
Payload: string(payload),
Type: "payload",
}, nil
}