Skip to content

Commit ec5e030

Browse files
committed
sync with fmp4 segments
1 parent 8ff8b4e commit ec5e030

File tree

3 files changed

+300
-114
lines changed

3 files changed

+300
-114
lines changed

internal/api/model/zbox.go

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -201,28 +201,29 @@ type ZboxJwtToken struct {
201201
JwtToken string `json:"jwt_token"`
202202
}
203203

204-
// ZboxTranscodingData represents the metadata stored for a transcoding upload.
205-
type ZboxTranscodingData struct {
206-
ID int `json:"ID"`
204+
// TranscodingEntity represents the transcoding entity metadata
205+
type TranscodingEntity struct {
206+
ID int64 `json:"ID"`
207207
UserID string `json:"UserID"`
208208
ClientID string `json:"ClientID"`
209-
LookupHash string `json:"LookupHash"`
210209
Remotepath string `json:"Remotepath"`
210+
FilePath string `json:"FilePath"`
211211
AllocationID string `json:"AllocationID"`
212212
FileName string `json:"FileName"`
213213
Mode string `json:"Mode"`
214214
FileSize int64 `json:"FileSize"`
215+
DoThumbnail bool `json:"DoThumbnail"`
215216
Status int `json:"Status"`
216217
AppType int `json:"AppType"`
217218
CreatedAt string `json:"CreatedAt"`
218219
UpdatedAt string `json:"UpdatedAt"`
219220
Deleted *string `json:"Deleted"`
220221
}
221222

222-
// ZboxTranscodingDataResponse wraps API responses for transcoding metadata endpoints.
223-
type ZboxTranscodingDataResponse struct {
224-
Message string `json:"message"`
225-
Data ZboxTranscodingData `json:"data"`
223+
// GetTranscodingEntityResponse wraps API responses for GET metadata endpoint
224+
type GetTranscodingEntityResponse struct {
225+
Message string `json:"message"`
226+
Data TranscodingEntity `json:"data"`
226227
}
227228

228229
type ReferralCodeOfUser struct {

internal/api/util/client/zbox_client.go

Lines changed: 103 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package client
22

33
import (
4+
"encoding/json"
45
"fmt"
56
"strconv"
67

@@ -1350,43 +1351,133 @@ func (c *ZboxClient) GetTransactionsList(t *test.SystemTest, pitId string) (*mod
13501351
}
13511352

13521353
// CreateMetadata posts transcoding metadata to the server and returns parsed response.
1353-
func (c *ZboxClient) CreateMetadata(t *test.SystemTest, headers map[string]string, body map[string]string) (*model.ZboxTranscodingDataResponse, *resty.Response, error) {
1354+
func (c *ZboxClient) CreateMetadata(t *test.SystemTest, headers map[string]string, body map[string]interface{}) (*model.TranscodingEntity, *resty.Response, error) {
13541355
t.Logf("creating transcoding metadata for user [%v] using 0box...", headers["X-App-User-ID"])
13551356

1356-
var res *model.ZboxTranscodingDataResponse
1357+
// Log request body
1358+
bodyJSON, err := json.Marshal(body)
1359+
if err == nil {
1360+
t.Logf("CreateMetadata request body: %s", string(bodyJSON))
1361+
} else {
1362+
t.Logf("CreateMetadata request body (marshal error): %v", body)
1363+
}
1364+
1365+
var res *model.GetTranscodingEntityResponse
13571366

13581367
urlBuilder := NewURLBuilder()
1359-
err := urlBuilder.MustShiftParse(c.zboxEntrypoint)
1368+
err = urlBuilder.MustShiftParse(c.zboxEntrypoint)
13601369
require.NoError(t, err, "URL parse error")
13611370
urlBuilder.SetPath("/v2/metadata")
13621371

1372+
// Ensure Content-Type is set to JSON
1373+
jsonHeaders := make(map[string]string)
1374+
for k, v := range headers {
1375+
jsonHeaders[k] = v
1376+
}
1377+
jsonHeaders["Content-Type"] = "application/json"
1378+
13631379
resp, err := c.executeForServiceProvider(t, urlBuilder.String(), model.ExecutionRequest{
13641380
Dst: &res,
1365-
Headers: headers,
1366-
FormData: body,
1381+
Headers: jsonHeaders,
1382+
Body: body,
13671383
RequiredStatusCode: 201,
13681384
}, HttpPOSTMethod)
13691385

1370-
return res, resp, err
1386+
if err != nil {
1387+
t.Errorf("CreateMetadata response error: %v, response body: %s", err, string(resp.Body()))
1388+
return nil, resp, err
1389+
}
1390+
1391+
// Log response body
1392+
t.Logf("CreateMetadata response status: %d, response body: %s", resp.StatusCode(), string(resp.Body()))
1393+
1394+
if res != nil && res.Data.ID != 0 {
1395+
return &res.Data, resp, nil
1396+
}
1397+
1398+
return nil, resp, fmt.Errorf("transcoding entity not found in response")
13711399
}
13721400

13731401
// UpdateUploadStatus updates status for an uploaded file and returns parsed response.
1374-
func (c *ZboxClient) UpdateUploadStatus(t *test.SystemTest, headers map[string]string, body map[string]string) (*model.ZboxTranscodingDataResponse, *resty.Response, error) {
1402+
func (c *ZboxClient) UpdateUploadStatus(t *test.SystemTest, headers map[string]string, body map[string]interface{}) (*model.TranscodingEntity, *resty.Response, error) {
13751403
t.Logf("updating upload status for user [%v] using 0box...", headers["X-App-User-ID"])
13761404

1377-
var res *model.ZboxTranscodingDataResponse
1405+
// Log request body
1406+
bodyJSON, err := json.Marshal(body)
1407+
if err == nil {
1408+
t.Logf("UpdateUploadStatus request body: %s", string(bodyJSON))
1409+
} else {
1410+
t.Logf("UpdateUploadStatus request body (marshal error): %v", body)
1411+
}
1412+
1413+
var res *model.GetTranscodingEntityResponse
13781414

13791415
urlBuilder := NewURLBuilder()
1380-
err := urlBuilder.MustShiftParse(c.zboxEntrypoint)
1416+
err = urlBuilder.MustShiftParse(c.zboxEntrypoint)
13811417
require.NoError(t, err, "URL parse error")
13821418
urlBuilder.SetPath("/v2/updateUploadStatus")
13831419

1420+
// Ensure Content-Type is set to JSON
1421+
jsonHeaders := make(map[string]string)
1422+
for k, v := range headers {
1423+
jsonHeaders[k] = v
1424+
}
1425+
jsonHeaders["Content-Type"] = "application/json"
1426+
13841427
resp, err := c.executeForServiceProvider(t, urlBuilder.String(), model.ExecutionRequest{
13851428
Dst: &res,
1386-
Headers: headers,
1387-
FormData: body,
1429+
Headers: jsonHeaders,
1430+
Body: body,
13881431
RequiredStatusCode: 201,
13891432
}, HttpPUTMethod)
13901433

1391-
return res, resp, err
1434+
if err != nil {
1435+
t.Errorf("UpdateUploadStatus response error: %v, response body: %s", err, string(resp.Body()))
1436+
return nil, resp, err
1437+
}
1438+
1439+
// Log response body
1440+
t.Logf("UpdateUploadStatus response status: %d, response body: %s", resp.StatusCode(), string(resp.Body()))
1441+
1442+
if res != nil && res.Data.ID != 0 {
1443+
return &res.Data, resp, nil
1444+
}
1445+
1446+
return nil, resp, fmt.Errorf("transcoding entity not found in response")
1447+
}
1448+
1449+
// GetMetadata gets transcoding entity metadata and returns parsed response.
1450+
func (c *ZboxClient) GetMetadata(t *test.SystemTest, headers map[string]string, queryParams map[string]string) (*model.TranscodingEntity, *resty.Response, error) {
1451+
t.Logf("getting transcoding metadata for user [%v] using 0box...", headers["X-App-User-ID"])
1452+
1453+
// Log query parameters
1454+
t.Logf("GetMetadata query params: %v", queryParams)
1455+
1456+
var res *model.GetTranscodingEntityResponse
1457+
1458+
urlBuilder := NewURLBuilder()
1459+
err := urlBuilder.MustShiftParse(c.zboxEntrypoint)
1460+
require.NoError(t, err, "URL parse error")
1461+
urlBuilder.SetPath("/v2/metadata")
1462+
1463+
resp, err := c.executeForServiceProvider(t, urlBuilder.String(), model.ExecutionRequest{
1464+
Dst: &res,
1465+
Headers: headers,
1466+
QueryParams: queryParams,
1467+
RequiredStatusCode: 200,
1468+
}, HttpGETMethod)
1469+
1470+
if err != nil {
1471+
t.Errorf("GetMetadata response error: %v, response body: %s", err, string(resp.Body()))
1472+
return nil, resp, err
1473+
}
1474+
1475+
// Log response body
1476+
t.Logf("GetMetadata response status: %d, response body: %s", resp.StatusCode(), string(resp.Body()))
1477+
1478+
if res != nil && res.Data.ID != 0 {
1479+
return &res.Data, resp, nil
1480+
}
1481+
1482+
return nil, resp, fmt.Errorf("transcoding entity not found in response")
13921483
}

0 commit comments

Comments
 (0)