MCPcopy Index your code
hub / github.com/LumaAI-API/Luma-API / getSignedUpload

Function getSignedUpload

luma.go:202–226  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

200}
201
202func 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
228func readImage(image string) (io.Reader, error) {
229 if strings.HasPrefix(image, "data:image/") {

Callers 1

uploadFileFunction · 0.85

Calls 2

DoRequestFunction · 0.85
GenLumaErrorFunction · 0.85

Tested by

no test coverage detected