Merge pull request #7857 from awanlin/bug/fix-s3-path-join

This commit is contained in:
Eric Peterson
2021-11-05 21:31:49 +01:00
committed by GitHub
3 changed files with 11 additions and 6 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/techdocs-common': patch
---
Updated to properly join URL segments under any OS for both AWS S3 and GCP
@@ -306,7 +306,7 @@ export class AwsS3Publish implements PublisherBase {
? entityTriplet
: lowerCaseEntityTriplet(entityTriplet);
const entityRootDir = path.join(this.bucketRootPath, entityDir);
const entityRootDir = path.posix.join(this.bucketRootPath, entityDir);
const stream = this.storageClient
.getObject({
@@ -357,7 +357,7 @@ export class AwsS3Publish implements PublisherBase {
: lowerCaseEntityTripletInStoragePath(decodedUriNoRoot);
// Re-prepend the root path to the relative file path
const filePath = path.join(this.bucketRootPath, filePathNoRoot);
const filePath = path.posix.join(this.bucketRootPath, filePathNoRoot);
// Files with different extensions (CSS, HTML) need to be served with different headers
const fileExtension = path.extname(filePath);
@@ -396,7 +396,7 @@ export class AwsS3Publish implements PublisherBase {
? entityTriplet
: lowerCaseEntityTriplet(entityTriplet);
const entityRootDir = path.join(this.bucketRootPath, entityDir);
const entityRootDir = path.posix.join(this.bucketRootPath, entityDir);
await this.storageClient
.headObject({
@@ -231,7 +231,7 @@ export class GoogleGCSPublish implements PublisherBase {
? entityTriplet
: lowerCaseEntityTriplet(entityTriplet);
const entityRootDir = path.join(this.bucketRootPath, entityDir);
const entityRootDir = path.posix.join(this.bucketRootPath, entityDir);
const fileStreamChunks: Array<any> = [];
this.storageClient
@@ -270,7 +270,7 @@ export class GoogleGCSPublish implements PublisherBase {
: lowerCaseEntityTripletInStoragePath(decodedUriNoRoot);
// Re-prepend the root path to the relative file path
const filePath = path.join(this.bucketRootPath, filePathNoRoot);
const filePath = path.posix.join(this.bucketRootPath, filePathNoRoot);
// Files with different extensions (CSS, HTML) need to be served with different headers
const fileExtension = path.extname(filePath);
@@ -310,7 +310,7 @@ export class GoogleGCSPublish implements PublisherBase {
? entityTriplet
: lowerCaseEntityTriplet(entityTriplet);
const entityRootDir = path.join(this.bucketRootPath, entityDir);
const entityRootDir = path.posix.join(this.bucketRootPath, entityDir);
this.storageClient
.bucket(this.bucketName)