Wie kann ich mit PHP ein Bild in Fedora Commons aufnehmen?

Ich versuche, ein Bild mit PHP in ein Fedora Commons-Repository aufzunehmen. Hier ist der Code, den ich benutze:

$queryArgs = array(
  "label" => "label goes here", 
  "format" => "info:fedora/fedora-system:METSFedoraExt-1.1", 
  "namespace" => $prefix, 
  "ownerID" => $fedoraUsername, 
  "logMessage" => "log message goes here"
);

$url = sprintf(
  "%s://%s:%d/%s/objects/%s?%s",
  "http",
  $host,
  $port,
  "fedora",
  $prefix . ":" . $identifier,
  http_build_query($queryArgs)
);
$headers = array("Accept: text/xml", "Content-Type: image/jpg");
$userPassword = $fedoraUsername . ":" . $fedoraPassword;
$verifyPeer = false;
$fileContents = file_get_contents("http://localhost/path/to/image.jpg");

$curlOptions = array(
  CURLOPT_URL => $url,
  CURLOPT_HTTPHEADER => $headers,
  CURLOPT_USERPWD => $userPassword,
  CURLOPT_HTTPAUTH => CURLAUTH_BASIC,
  CURLOPT_SSL_VERIFYPEER => $verifyPeer,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_POST => true,
  CURLOPT_POSTFIELDS => $fileContents
);

$curlHandle = curl_init();
curl_setopt_array($curlHandle, $curlOptions);
curl_exec($curlHandle);
error_log(print_r(curl_getinfo($curlHandle), true));

Am Ende drucke ich was auscurl_getinfo muss vor allem sagen[http_code] => 415.

HTTP-Fehler 415 Nicht unterstützter Medientyp

Was mache ich hier falsch?

Antworten auf die Frage(1)

Ihre Antwort auf die Frage