Skip to content

Commit

Permalink
1.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
NimperX committed Jun 3, 2021
1 parent deee23f commit 3b2bbe5
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 11 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-aws-s3-typescript",
"version": "1.0.2",
"version": "1.1.0",
"description": "Open source npm package to upload your files into AWS S3 Bucket directly using react(typescript template)",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion src/ErrorThrower.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ export const throwUploadError = (config: IConfig, file: File) => {
if (!file) {
throw new Error(`File cannot be empty`);
}
}
};
16 changes: 9 additions & 7 deletions src/react-aws-s3.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,35 +93,37 @@ class ReactS3Client {
});

try {
const req = await s3.listObjects({
Bucket: this.config.bucketName,
}).promise();
const req = await s3
.listObjects({
Bucket: this.config.bucketName,
})
.promise();

if (req.$response.error) {
return Promise.reject<ListFileErrorResponse>({
err: req.$response.error.name,
errMessage: req.$response.error.message,
data: req.$response.error
data: req.$response.error,
});
}

if (!req.$response.data) {
return Promise.reject<ListFileErrorResponse>({
err: 'Something went wrong!',
errMessage: 'Unknown error occured. Please try again',
data: null
data: null,
});
}

return Promise.resolve<ListFileResponse>({
message: 'Objects listed succesfully',
data: req.$response.data
data: req.$response.data,
});
} catch (err) {
return Promise.reject<ListFileErrorResponse>({
err: 'Something went wrong!',
errMessage: 'Unknown error occured. Please try again',
data: err
data: err,
});
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export type DeleteResponse = {

export type ListFileResponse = {
message: string;
data: AWS.S3.ListObjectsOutput
data: AWS.S3.ListObjectsOutput;
};

export type ListFileErrorResponse = {
Expand Down

0 comments on commit 3b2bbe5

Please sign in to comment.