public function importResource($source, $collectionName)
{
$temporaryTargetPathAndFilename = $this->environment->getPathToTemporaryDirectory() . uniqid('TYPO3_Flow_ResourceImport_');
if (is_resource($source)) {
try {
$target = fopen($temporaryTargetPathAndFilename, 'wb');
stream_copy_to_stream($source, $target);
fclose($target);
} catch (\Exception $exception) {
throw new StorageException(sprintf('Could import the content stream to temporary file "%s".', $temporaryTargetPathAndFilename), 1380880079);
}
} else {
try {
copy($source, $temporaryTargetPathAndFilename);
} catch (\Exception $exception) {
throw new StorageException(sprintf('Could not copy the file from "%s" to temporary file "%s".', $source, $temporaryTargetPathAndFilename), 1375198876);
}
}
return $this->importTemporaryFile($temporaryTargetPathAndFilename, $collectionName);
}