protected function AcquiaDAMStreamWrapper::getStreamContent in Media: Acquia DAM 7
Fetch the content of the file using drupal_http_request().
Overrides DrupalRemoteStreamWrapper::getStreamContent
File
- includes/
AcquiaDAMStreamWrapper.inc, line 21 - Create an Acquia DAM Stream Wrapper class for the Media/Resource module.
Class
- AcquiaDAMStreamWrapper
- Provides a remote stream wrapper for Acquia DAM assets.
Code
protected function getStreamContent() {
if (!isset($this->stream_content)) {
$this->stream_content = NULL;
// Translate our acquiadam:// uri into a remote URL before we make the
// request.
$uri = file_create_url($this->uri);
$request = drupal_http_request($uri);
if (empty($request->error) && !empty($request->data)) {
$this->stream_content = $request->data;
}
elseif (!empty($request->error)) {
watchdog('media_acquiadam', '(@code) Error fetching asset content: @error', [
'@code' => $request->code,
'@error' => $request->error,
], WATCHDOG_NOTICE, l(t('View'), $uri));
}
}
return $this->stream_content;
}