Changeset View
Changeset View
Standalone View
Standalone View
lib/Kolab/DAV/Node.php
Show First 20 Lines • Show All 164 Lines • ▼ Show 20 Lines | protected function fileData($name, $data = null) | ||||
$type = $this->data['type']; | $type = $this->data['type']; | ||||
} | } | ||||
else { | else { | ||||
$type = 'application/octet-stream'; | $type = 'application/octet-stream'; | ||||
} | } | ||||
// $data can be a resource or a string | // $data can be a resource or a string | ||||
if (is_resource($data)) { | if (is_resource($data)) { | ||||
rewind($data); | |||||
// $data can be php://input or php://temp | // $data can be php://input or php://temp | ||||
// php://input is not seekable, we need to "convert" | // php://input is not seekable, we need to "convert" | ||||
// it to seekable resource, fstat/rewind later will work | // it to seekable resource, fstat/rewind later will work | ||||
$meta = stream_get_meta_data($data); | $meta = stream_get_meta_data($data); | ||||
if (!$meta['seekable']) { | if (!$meta['seekable']) { | ||||
$new_data = fopen('php://temp','r+'); | $new_data = fopen('php://temp','r+'); | ||||
stream_copy_to_stream($data, $new_data); | stream_copy_to_stream($data, $new_data); | ||||
rewind($new_data); | rewind($new_data); | ||||
$data = $new_data; | $data = $new_data; | ||||
} | } | ||||
else { | |||||
rewind($data); | |||||
} | |||||
} | } | ||||
$filedata = array( | $filedata = array( | ||||
'content' => $data, | 'content' => $data, | ||||
'type' => $type, | 'type' => $type, | ||||
); | ); | ||||
return $filedata; | return $filedata; | ||||
Show All 23 Lines |