Skip to content

Commit

Permalink
Merge pull request #527 from Pinelab-studio/fix/google-storage-v3
Browse files Browse the repository at this point in the history
feat(google-storage-assets): admin assetserver support for vendure v3
  • Loading branch information
martijnvdbrug authored Oct 31, 2024
2 parents 08a07cb + dd36163 commit 5df4d59
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
4 changes: 4 additions & 0 deletions packages/vendure-plugin-google-storage-assets/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# 1.2.2 (2024-10-31)

- Use asset server for admin with Vendure V3 support

# 1.2.1 (2024-08-04)

- Update compatibility range (#480)
Expand Down
2 changes: 1 addition & 1 deletion packages/vendure-plugin-google-storage-assets/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pinelab/vendure-plugin-google-storage-assets",
"version": "1.2.1",
"version": "1.2.2",
"description": "Vendure plugin for uploading assets to Google storage",
"author": "Martijn van de Brug <[email protected]>",
"homepage": "https://pinelab-plugins.com/",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,11 @@ export class GoogleStorageStrategy implements AssetStorageStrategy {
}

toAbsoluteUrl(request: Request | undefined, identifier: string): string {
if (
this.useAssetServerForAdminUi &&
(request as any)?.vendureRequestContext?._apiType === 'admin'
) {
// Vendure v3 has an extra 'default' property before we can access the apiType
const apiType =
(request as any)?.vendureRequestContext?.default?._apiType ||
(request as any)?.vendureRequestContext?._apiType;
if (this.useAssetServerForAdminUi && apiType === 'admin') {
// go via assetServer if admin
return `${request!.protocol}://${request!.get(
'host'
Expand Down Expand Up @@ -82,6 +83,7 @@ export class GoogleStorageStrategy implements AssetStorageStrategy {
destination: fileName,
});
if (fileName.startsWith('preview/')) {
// For each preview, we also generate a thumbnail version
await this.writeThumbnail(fileName, tmpFile.name);
}
return fileName;
Expand Down

0 comments on commit 5df4d59

Please sign in to comment.