Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 6 additions & 16 deletions lib/Service/RemoteService.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,8 @@ public function fetchTargetThumbnail(File $file, string $target): ?string {
* @return resource|string
*/
public function convertFileTo(File $file, string $format) {
$useTempFile = $file->isEncrypted() || !$file->getStorage()->isLocal();
if ($useTempFile) {
$fileName = $file->getStorage()->getLocalFile($file->getInternalPath());
$stream = fopen($fileName, 'r');
} else {
$stream = $file->fopen('r');
}
$fileName = $file->getStorage()->getLocalFile($file->getInternalPath());
$stream = fopen($fileName, 'rb');

if ($stream === false) {
throw new Exception('Failed to open stream');
Expand Down Expand Up @@ -98,16 +93,11 @@ public function convertTo(string $filename, $stream, string $format) {
}

private function getRequestOptionsForFile(File $file, ?string $target = null): array {
$useTempFile = $file->isEncrypted() || !$file->getStorage()->isLocal();
if ($useTempFile) {
$localFile = $file->getStorage()->getLocalFile($file->getInternalPath());
if (!is_string($localFile)) {
throw new NotFoundException('Could not get local file');
}
$stream = fopen($localFile, 'rb');
} else {
$stream = $file->fopen('rb');
$localFile = $file->getStorage()->getLocalFile($file->getInternalPath());
if (!is_string($localFile)) {
throw new NotFoundException('Could not get local file');
}
$stream = fopen($localFile, 'rb');

$options = RemoteOptionsService::getDefaultOptions(25);
$options['multipart'] = [
Expand Down
Loading