Skip to content

Commit

Permalink
Merge branch '2.0' into 2.1
Browse files Browse the repository at this point in the history
  • Loading branch information
medz committed Oct 31, 2018
2 parents a327e0b + 0009250 commit 5ba5e49
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 10 deletions.
8 changes: 6 additions & 2 deletions app/FileStorage/Filesystems/AliyunOss/FileMeta.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ class FileMeta extends FileMetaAbstract
protected $resource;
protected $bucket;
protected $dimension;
protected $cachedMeta;

/**
* Create a file meta.
Expand All @@ -51,6 +52,7 @@ public function __construct(OssClient $oss, ResourceInterface $resource, string
$this->oss = $oss;
$this->resource = $resource;
$this->bucket = $bucket;
$this->getSize();
}

/**
Expand Down Expand Up @@ -94,9 +96,11 @@ public function getImageDimension(): ImageDimensionInterface
*/
public function getSize(): int
{
$meta = $this->oss->getObjectMeta($this->bucket, $this->resource->getPath());
if (! $this->cachedMeta) {
$this->cachedMeta = $this->oss->getObjectMeta($this->bucket, $this->resource->getPath());
}

return (int) $meta['content-length'];
return (int) $this->cachedMeta['content-length'];
}

/**
Expand Down
2 changes: 1 addition & 1 deletion app/FileStorage/Filesystems/Local/FileMeta.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ public function __construct(FilesystemContract $filesystem, ResourceInterface $r
{
$this->filesystem = $filesystem;
$this->resource = $resource;
$this->hasImage();
}

/**
Expand All @@ -75,7 +76,6 @@ protected function useCustomTypes(): ?Closure
'image/jpeg',
'image/png',
'image/gif',
// 'image/bmp',
'image/webp',
];
};
Expand Down
7 changes: 1 addition & 6 deletions app/FileStorage/Traits/EloquentAttributeTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,10 @@ protected function getFileStorageInstance(): StorageInterface
*/
protected function getFileStorageResourceMeta(string $resource): ?FileMetaInterface
{
// Is local mode, throw exceptions.
if (app()->isLocal()) {
return $this->getFileStorageInstance()->meta(new Resource($resource));
}

try {
return $this->getFileStorageInstance()->meta(new Resource($resource));
} catch (Exception $e) {
return $resource;
return null;
}

return $resource;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -416,10 +416,13 @@ public function newStore(
});
}

$map = $request->only(['title', 'content', 'subject']);
$map = $request->only(['title', 'subject']);
$map['from'] = $request->input('from') ?: '原创';
$map['author'] = $request->input('author') ?: $user->name;
$map['storage'] = $request->input('image');
$map['content'] = $this->app->make(Markdown::class)->safetyMarkdown(
$request->input('content', '')
);

$images = $this->findMarkdownImageNotWithModels($map['content'] ?: '');
// 提取内容中的图片,用于列表种的多种UI展示
Expand Down

0 comments on commit 5ba5e49

Please sign in to comment.