$data['url'] = $this->url;
}
if ($this->type !== null) {
- $data['type'] = 'h-' . $this->type;
+ $data['type'] = array('h-' . $this->type);
}
if (count($this->properties)) {
$data['properties'] = $this->properties;
);
$shown = false;
- if ($res->getHeader('content-type') == 'application/json') {
+ if (Util::getMimeType($res) == 'application/json') {
$errData = json_decode($res->getBody());
if (!isset($errData->error)) {
Log::err('Error response does not contain "error" property');
}
/**
+ * Add file upload
+ *
* @param string $fieldName name of file-upload field
* @param array $fileNames list of local file paths
+ *
+ * @return void
*/
public function addUpload($fieldName, $fileNames)
{
+ if ($this->directUpload && $this->sendAsJson) {
+ throw new \Exception(
+ 'Cannot do direct upload with JSON requests'
+ );
+ }
+
if ($this->host->endpoints->media === null
|| $this->directUpload
) {
}
/**
+ * Execute the file upload
+ *
+ * @param string $fileName File path
+ *
* @return string URL at media endpoint
*/
public function uploadToMediaEndpoint($fileName)
{
if ($isHtml) {
$this->addProperty(
- 'content', ['html' => $text]
+ 'content', [['html' => $text]]
);
} else {
$this->addProperty('content', $text);
*
* @param string $key Parameter name
* @param string|array $values One or multiple values
+ *
+ * @return void
*/
public function addProperty($key, $values)
{