Skip to content
Closed
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion .github/workflows/ci-code-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ env:

jobs:
code-check:
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04

name: ${{ matrix.check == 'ts' && 'TypeScript' || 'Code Lint' }}

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci-test-e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ env:

jobs:
test:
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
env:
RC_DOCKERFILE: ${{ inputs.rc-dockerfile }}.${{ (matrix.mongodb-version == '7.0' && 'debian' && false) || 'alpine' }}
RC_DOCKER_TAG: ${{ inputs.rc-docker-tag }}.${{ (matrix.mongodb-version == '7.0' && 'debian' && false) || 'alpine' }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci-test-unit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ env:

jobs:
test:
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04

name: Unit Tests

Expand Down
22 changes: 11 additions & 11 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ jobs:

notify-draft-services:
name: 🚀 Notify external services - draft
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
needs: [release-versions]
steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -136,7 +136,7 @@ jobs:
packages-build:
name: 📦 Build Packages
needs: [release-versions, notify-draft-services]
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
steps:
- name: Github Info
run: |
Expand Down Expand Up @@ -225,7 +225,7 @@ jobs:
build:
name: 📦 Meteor Build - coverage
needs: [release-versions, packages-build]
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04

steps:
- name: Collect Workflow Telemetry
Expand Down Expand Up @@ -256,7 +256,7 @@ jobs:
name: 📦 Meteor Build - official
needs: [tests-done, release-versions, packages-build]
if: (github.event_name == 'release' || github.ref == 'refs/heads/develop')
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04

steps:
- name: Collect Workflow Telemetry
Expand Down Expand Up @@ -331,7 +331,7 @@ jobs:
build-gh-docker-coverage:
name: 🚢 Build Docker Images for Testing
needs: [build, release-versions, build-matrix-rust-bindings-for-alpine]
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04

env:
RC_DOCKERFILE: ${{ needs.release-versions.outputs.rc-dockerfile }}.${{ matrix.platform }}
Expand Down Expand Up @@ -376,7 +376,7 @@ jobs:
build-gh-docker:
name: 🚢 Build Docker Images for Production
needs: [build-prod, release-versions]
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04

env:
RC_DOCKERFILE: ${{ needs.release-versions.outputs.rc-dockerfile }}.${{ matrix.platform }}
Expand Down Expand Up @@ -563,7 +563,7 @@ jobs:

tests-done:
name: ✅ Tests Done
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
needs: [checks, test-unit, test-api, test-ui, test-api-ee, test-ui-ee, test-ui-ee-no-watcher]
if: always()
steps:
Expand Down Expand Up @@ -601,7 +601,7 @@ jobs:

deploy:
name: 🚀 Publish build assets
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
if: github.event_name == 'release' || github.ref == 'refs/heads/develop'
needs: [build-gh-docker, release-versions]

Expand Down Expand Up @@ -655,7 +655,7 @@ jobs:

docker-image-publish:
name: 🚀 Publish Docker Image (main)
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
needs: [deploy, release-versions]

strategy:
Expand Down Expand Up @@ -765,7 +765,7 @@ jobs:

services-docker-image-publish:
name: 🚀 Publish Docker Image (services)
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
needs: [deploy, release-versions]

strategy:
Expand Down Expand Up @@ -854,7 +854,7 @@ jobs:

notify-services:
name: 🚀 Notify external services
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
needs:
- services-docker-image-publish
- docker-image-publish
Expand Down
25 changes: 18 additions & 7 deletions apps/meteor/app/file-upload/ufs/AmazonS3/server.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import stream from 'stream';
import type { ReadableStream } from 'stream/web';

import { S3, GetObjectCommand } from '@aws-sdk/client-s3';
import { getSignedUrl } from '@aws-sdk/s3-request-presigner';
import type { IUpload } from '@rocket.chat/core-typings';
import { Random } from '@rocket.chat/random';
import S3 from 'aws-sdk/clients/s3';
import { check } from 'meteor/check';
import type { OptionalId } from 'mongodb';
import _ from 'underscore';
Expand Down Expand Up @@ -31,6 +33,8 @@ export type S3Options = StoreOptions & {
class AmazonS3Store extends UploadFS.Store {
protected getPath: (file: IUpload) => string;

private bucketName: string;

constructor(options: S3Options) {
// Default options
// options.secretAccessKey,
Expand All @@ -50,6 +54,8 @@ class AmazonS3Store extends UploadFS.Store {

super(options);

this.bucketName = options.connection.params.Bucket;

const classOptions = options;

const s3 = new S3(options.connection);
Expand All @@ -74,13 +80,13 @@ class AmazonS3Store extends UploadFS.Store {
};

this.getRedirectURL = async (file, forceDownload = false) => {
const params = {
const getObject = new GetObjectCommand({
Key: this.getPath(file),
Expires: classOptions.URLExpiryTimeSpan,
Bucket: this.bucketName,
ResponseContentDisposition: `${forceDownload ? 'attachment' : 'inline'}; filename="${encodeURI(file.name || '')}"`,
};
});

return s3.getSignedUrlPromise('getObject', params);
return getSignedUrl(s3, getObject, { expiresIn: classOptions.URLExpiryTimeSpan });
};

/**
Expand Down Expand Up @@ -121,7 +127,7 @@ class AmazonS3Store extends UploadFS.Store {
};

try {
return s3.deleteObject(params).promise();
return s3.deleteObject(params);
} catch (err: any) {
SystemLogger.error(err);
}
Expand All @@ -148,7 +154,12 @@ class AmazonS3Store extends UploadFS.Store {
params.Range = `${options.start} - ${options.end}`;
}

return s3.getObject(params).createReadStream();
const { Body: body } = await s3.getObject(params);
if (!body) {
throw new Error('failed to get object from s3');
}

return stream.Readable.fromWeb(body.transformToWebStream() as ReadableStream);
};

/**
Expand Down
3 changes: 2 additions & 1 deletion apps/meteor/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,8 @@
"typescript": "~5.7.2"
},
"dependencies": {
"@aws-sdk/client-s3": "^3.758.0",
"@aws-sdk/s3-request-presigner": "^3.758.0",
"@babel/runtime": "~7.26.0",
"@bugsnag/js": "~7.20.2",
"@bugsnag/plugin-react": "~7.19.0",
Expand Down Expand Up @@ -303,7 +305,6 @@
"archiver": "^7.0.1",
"asterisk-manager": "^0.2.0",
"atlassian-crowd-patched": "^0.5.1",
"aws-sdk": "^2.1691.0",
"bad-words": "^3.0.4",
"bcrypt": "^5.1.1",
"body-parser": "1.20.3",
Expand Down
Loading