()
| 200 | } |
| 201 | |
| 202 | func getSignedUpload() (*FileUploadResult, *WrapperErrorResp) { |
| 203 | url := common.BaseUrl + FileUploadEndpoint + "?file_type=image&filename=file.jpg" |
| 204 | |
| 205 | resp, err := DoRequest(http.MethodPost, url, nil, nil) |
| 206 | if err != nil { |
| 207 | return nil, GenLumaError(err, http.StatusInternalServerError) |
| 208 | } |
| 209 | |
| 210 | defer resp.Body.Close() |
| 211 | body, err := io.ReadAll(resp.Body) |
| 212 | if err != nil { |
| 213 | return nil, GenLumaError(err, http.StatusInternalServerError) |
| 214 | } |
| 215 | |
| 216 | if resp.StatusCode >= 400 { |
| 217 | return nil, GenLumaError(fmt.Errorf(string(body)), resp.StatusCode) |
| 218 | } |
| 219 | |
| 220 | var result FileUploadResult |
| 221 | err = json.Unmarshal(body, &result) |
| 222 | if err != nil { |
| 223 | return nil, GenLumaError(err, http.StatusInternalServerError) |
| 224 | } |
| 225 | return &result, nil |
| 226 | } |
| 227 | |
| 228 | func readImage(image string) (io.Reader, error) { |
| 229 | if strings.HasPrefix(image, "data:image/") { |
no test coverage detected