Skip to content

Commit 4209600

Browse files
committed
put files and urls at the end of formData, fixes #18
1 parent 361348d commit 4209600

File tree

1 file changed

+36
-30
lines changed

1 file changed

+36
-30
lines changed

src/OpencastApi/Rest/OcIngest.php

Lines changed: 36 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public function __construct($restClient)
1313

1414
/**
1515
* Create an empty media package.
16-
*
16+
*
1717
* @return array the response result ['code' => 200, 'body' => '{XML (text) media package}']
1818
*/
1919
public function createMediaPackage()
@@ -39,13 +39,14 @@ public function addCatalog($mediaPackage, $flavor, $file, $tags = '')
3939
$formData = [
4040
'mediaPackage' => $mediaPackage,
4141
'flavor' => $flavor,
42-
'dublincore-episode.xml' => $file
4342
];
4443

4544
if (!empty($tags)) {
4645
$formData['tags'] = $tags;
4746
}
4847

48+
$formData['BODY'] = $file;
49+
4950
$options = $this->restClient->getMultiPartFormParams($formData);
5051
return $this->restClient->performPost($uri, $options);
5152
}
@@ -67,13 +68,14 @@ public function addCatalogUrl($mediaPackage, $flavor, $url, $tags = '')
6768
$formData = [
6869
'mediaPackage' => $mediaPackage,
6970
'flavor' => $flavor,
70-
'url' => $url
7171
];
7272

7373
if (!empty($tags)) {
7474
$formData['tags'] = $tags;
7575
}
7676

77+
$formData['url'] = $url;
78+
7779
$options = $this->restClient->getFormParams($formData);
7880
return $this->restClient->performPost($uri, $options);
7981
}
@@ -84,7 +86,7 @@ public function addCatalogUrl($mediaPackage, $flavor, $url, $tags = '')
8486
* @param string $mediaPackage The media package
8587
* @param string $dublinCore DublinCore catalog
8688
* @param string $flavor (optional) DublinCore Flavor (Default value=dublincore/episode)
87-
*
89+
*
8890
* @return array the response result ['code' => 200, 'body' => '{XML (text) augmented media package}']
8991
*/
9092
public function addDCCatalog($mediaPackage, $dublinCore, $flavor = '')
@@ -99,7 +101,7 @@ public function addDCCatalog($mediaPackage, $dublinCore, $flavor = '')
99101
$formData['flavor'] = $flavor;
100102
}
101103

102-
$options = $this->restClient->getFormParams($formData);
104+
$options = $this->restClient->getFormParams($formData);
103105
return $this->restClient->performPost($uri, $options);
104106
}
105107

@@ -120,13 +122,14 @@ public function addAttachment($mediaPackage, $flavor, $file, $tags = '')
120122
$formData = [
121123
'mediaPackage' => $mediaPackage,
122124
'flavor' => $flavor,
123-
'attachment.xml' => $file
124125
];
125126

126127
if (!empty($tags)) {
127128
$formData['tags'] = $tags;
128129
}
129130

131+
$formData['BODY'] = $file;
132+
130133
$options = $this->restClient->getMultiPartFormParams($formData);
131134
return $this->restClient->performPost($uri, $options);
132135
}
@@ -148,27 +151,28 @@ public function addAttachmentUrl($mediaPackage, $flavor, $url, $tags = '')
148151
$formData = [
149152
'mediaPackage' => $mediaPackage,
150153
'flavor' => $flavor,
151-
'url' => $url
152154
];
153155

154156
if (!empty($tags)) {
155157
$formData['tags'] = $tags;
156158
}
157159

160+
$formData['url'] = $url;
161+
158162
$options = $this->restClient->getFormParams($formData);
159163
return $this->restClient->performPost($uri, $options);
160164
}
161165

162166
/**
163167
* Create and ingest media package from media tracks with additional Dublin Core metadata.
164-
* It is mandatory to set a title for the recording. This can be done with the 'title' form field or by supplying a DC catalog with a title included.
168+
* It is mandatory to set a title for the recording. This can be done with the 'title' form field or by supplying a DC catalog with a title included.
165169
* (deprecated*) The identifier of the newly created media package will be taken from the identifier field or the episode DublinCore catalog (deprecated*).
166170
* If no identifier is set, a new random UUIDv4 will be generated. This endpoint is not meant to be used by capture agents for scheduled recordings. Its primary use is for manual ingests with command line tools like cURL.
167-
*
171+
*
168172
* Multiple tracks can be ingested by using multiple form fields. It is important to always set the flavor of the next media file before sending the media file itself.
169-
*
170-
* (*) The special treatment of the identifier field is deprecated and may be removed in future versions without further notice in favor of a random UUID generation to ensure uniqueness of identifiers.
171-
*
173+
*
174+
* (*) The special treatment of the identifier field is deprecated and may be removed in future versions without further notice in favor of a random UUID generation to ensure uniqueness of identifiers.
175+
*
172176
*
173177
* @param array $flavor (optional) The kind of media track. This has to be specified prior to each media track (default: "presenter/source"):
174178
* @param array $file (partially optional) media track file, could be null if mediaUri in $params is defined.
@@ -205,15 +209,15 @@ public function addAttachmentUrl($mediaPackage, $flavor, $url, $tags = '')
205209
* 'type' => '', // Episode metadata value.
206210
* 'episodeDCCatalogUri' => '', // URL of episode DublinCore Catalog.
207211
* 'episodeDCCatalog' => '', // URL of episode DublinCore Catalog.
208-
* 'seriesDCCatalogUri' => '', // URL of series DublinCore Catalog
209-
* 'seriesDCCatalog' => '', // Series DublinCore Catalog
210-
* 'acl' => '', // Access control list in XACML or JSON form
212+
* 'seriesDCCatalogUri' => '', // URL of series DublinCore Catalog
213+
* 'seriesDCCatalog' => '', // Series DublinCore Catalog
214+
* 'acl' => '', // Access control list in XACML or JSON form
211215
* 'tag' => '', // Tag of the next media file
212216
* 'mediaUri' => '', // URL of a media track file
213217
* ]
214-
*
218+
*
215219
* @param string $wdID (optional) Workflow definition id
216-
*
220+
*
217221
* @return array the response result ['code' => 200, 'body' => '{Ingest successful. Returns workflow instance as XML (text)']
218222
*/
219223
public function addMediaPackage($flavor = 'presenter/source', $file = null, $params = [], $wdID = '')
@@ -243,7 +247,7 @@ public function addMediaPackage($flavor = 'presenter/source', $file = null, $par
243247
} else {
244248
$options = $this->restClient->getFormParams($formData);
245249
}
246-
250+
247251
return $this->restClient->performPost($uri, $options);
248252
}
249253

@@ -268,7 +272,7 @@ public function addZippedMediaPackage($zipFile, $workflowDefinitionId, $workflow
268272
$formData['workflowInstanceId'] = $workflowInstanceId;
269273
}
270274

271-
$options = $this->restClient->getMultiPartFormParams($formData);
275+
$options = $this->restClient->getMultiPartFormParams($formData);
272276
return $this->restClient->performPost($uri, $options);
273277
}
274278

@@ -305,7 +309,7 @@ public function discardMediaPackage($mediaPackage)
305309
* Add a partial media track to a given media package using an input stream
306310
*
307311
* @param string $mediaPackage The XML media package as string
308-
* @param string $flavor The kind of media track
312+
* @param string $flavor The kind of media track
309313
* @param object $file The media track file
310314
* @param int $startTime The start time in milliseconds
311315
*
@@ -319,18 +323,18 @@ public function addPartialTrack($mediaPackage, $flavor, $file, $startTime = 0)
319323
'mediaPackage' => $mediaPackage,
320324
'flavor' => $flavor,
321325
'startTime' => $startTime,
322-
'track.mp4' => $file
326+
'BODY' => $file
323327
];
324328

325-
$options = $this->restClient->getMultiPartFormParams($formData);
329+
$options = $this->restClient->getMultiPartFormParams($formData);
326330
return $this->restClient->performPost($uri, $options);
327331
}
328332

329333
/**
330334
* Add a partial media track to a given media package using an URL
331335
*
332336
* @param string $mediaPackage The XML media package as string
333-
* @param string $flavor The kind of media track
337+
* @param string $flavor The kind of media track
334338
* @param string $url The location of the media
335339
* @param int $startTime The start time in milliseconds
336340
*
@@ -347,13 +351,13 @@ public function addPartialTrackUrl($mediaPackage, $flavor, $url, $startTime = 0)
347351
'url' => $url
348352
];
349353

350-
$options = $this->restClient->getFormParams($formData);
354+
$options = $this->restClient->getFormParams($formData);
351355
return $this->restClient->performPost($uri, $options);
352356
}
353357

354358
/**
355359
* Add a media track to a given media package using an input stream
356-
*
360+
*
357361
* @param string $mediaPackage The media package
358362
* @param string $flavor The kind of media track
359363
* @param object $file The media track file
@@ -375,13 +379,14 @@ public function addTrack($mediaPackage, $flavor, $file, $tags = '', $progressCal
375379
$formData = [
376380
'mediaPackage' => $mediaPackage,
377381
'flavor' => $flavor,
378-
'track.mp4' => $file
379382
];
380383

381384
if (!empty($tags)) {
382385
$formData['tags'] = $tags;
383386
}
384387

388+
$formData['BODY'] = $file;
389+
385390
$options = $this->restClient->getMultiPartFormParams($formData);
386391
if (!empty($progressCallable)) {
387392
$options['progress'] = $progressCallable;
@@ -392,7 +397,7 @@ public function addTrack($mediaPackage, $flavor, $file, $tags = '', $progressCal
392397

393398
/**
394399
* Add a media track to a given media package using an URL
395-
*
400+
*
396401
* @param string $mediaPackage The media package
397402
* @param string $flavor The kind of media track
398403
* @param string $url The location of the media
@@ -407,14 +412,15 @@ public function addTrackUrl($mediaPackage, $flavor, $url, $tags = '')
407412
$formData = [
408413
'mediaPackage' => $mediaPackage,
409414
'flavor' => $flavor,
410-
'url' => $url
411415
];
412416

413417
if (!empty($tags)) {
414418
$formData['tags'] = $tags;
415419
}
416420

417-
$options = $this->restClient->getFormParams($formData);
421+
$formData['url'] = $url;
422+
423+
$options = $this->restClient->getFormParams($formData);
418424
return $this->restClient->performPost($uri, $options);
419425
}
420426

@@ -472,4 +478,4 @@ public function schedule($mediaPackage, $workflowDefinitionId = '')
472478
return $this->restClient->performPost($uri, $options);
473479
}
474480
}
475-
?>
481+
?>

0 commit comments

Comments
 (0)