Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Respect AWS_S3_BUCKET #12

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions backend/src/routes/api/buckets/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export default async (fastify: FastifyInstance): Promise<void> => {
const { Owner, Buckets } = await s3Client.send(command);
reply.send({
owner: Owner,
defaultBucket: process.env.AWS_S3_BUCKET || '',
buckets: Buckets,
});
} catch (error) {
Expand Down
2 changes: 2 additions & 0 deletions frontend/src/app/components/ObjectBrowser/ObjectBrowser.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,13 @@ const ObjectBrowser: React.FC<ObjectBrowserProps> = () => {
// Load buckets at startup and when location changes
React.useEffect(() => {
loadBuckets(bucketName, history, setBucketsList);
setFormSelectBucket(bucketName);
}, [location]);

// Refresh objects from the bucket when location changes
React.useEffect(() => {
refreshObjects(bucketName, prefix, setDecodedPrefix, setS3Objects, setS3Prefixes);
setFormSelectBucket(bucketName);
}, [location, prefix]);

// Handle bucket change in the dropdown
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,18 @@ import Emitter from '../../utils/emitter';
export const loadBuckets = (bucketName: string, history, setBucketsList) => {
axios.get(`${config.backend_api_url}/buckets`)
.then(response => {
const { owner, buckets } = response.data;
const { owner, defaultBucket, buckets } = response.data;
const newBucketsState = new BucketsList(
buckets.map((bucket: any) => new Bucket(bucket.Name, bucket.CreationDate)),
new Owner(owner.DisplayName, owner.ID)
);
setBucketsList(newBucketsState);
if (bucketName === ":bucketName") {
history.push(`/objects/${buckets[0].Name}`);
if ( defaultBucket !== '' )
history.push(`/objects/${defaultBucket}`);
else {
history.push(`/objects/${buckets[0].Name}`);
}
}
})
.catch(error => {
Expand Down