Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-aws-s3-typescript

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-aws-s3-typescript - npm Package Compare versions

Comparing version 1.0.2 to 1.1.0

3

dist/ErrorThrower.d.ts
import { IConfig } from './types';
export declare const throwError: (config: IConfig, file: File) => void;
export declare const throwError: (config: IConfig) => void;
export declare const throwUploadError: (config: IConfig, file: File) => void;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.throwError = void 0;
var throwError = function (config, file) {
exports.throwUploadError = exports.throwError = void 0;
var throwError = function (config) {
if (config.bucketName === null || config.bucketName === '') {

@@ -17,2 +17,6 @@ throw new Error("Your bucketName cannot be empty ");

}
};
exports.throwError = throwError;
var throwUploadError = function (config, file) {
exports.throwError(config);
if (!file) {

@@ -22,2 +26,2 @@ throw new Error("File cannot be empty");

};
exports.throwError = throwError;
exports.throwUploadError = throwUploadError;

@@ -1,2 +0,2 @@

import { IConfig, UploadResponse } from './types';
import { IConfig, ListFileErrorResponse, ListFileResponse, UploadResponse } from './types';
declare class ReactS3Client {

@@ -7,3 +7,4 @@ private config;

deleteFile(key: string): Promise<void>;
listFiles(): Promise<ListFileResponse | ListFileErrorResponse>;
}
export default ReactS3Client;

@@ -59,3 +59,3 @@ "use strict";

case 0:
ErrorThrower_1.throwError(this.config, file);
ErrorThrower_1.throwUploadError(this.config, file);
fd = new FormData();

@@ -129,4 +129,61 @@ if (file.type == null) {

};
ReactS3Client.prototype.listFiles = function () {
return __awaiter(this, void 0, void 0, function () {
var awsConfig, s3, req, err_1;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
awsConfig = (function (_a) {
var region = _a.region, accessKeyId = _a.accessKeyId, secretAccessKey = _a.secretAccessKey;
return ({ region: region, accessKeyId: accessKeyId, secretAccessKey: secretAccessKey });
})(this.config);
aws_sdk_1.default.config.update(awsConfig);
s3 = new aws_sdk_1.default.S3({
apiVersion: '2006-03-01',
params: {
Bucket: this.config.bucketName,
},
});
_a.label = 1;
case 1:
_a.trys.push([1, 3, , 4]);
return [4 /*yield*/, s3
.listObjects({
Bucket: this.config.bucketName,
})
.promise()];
case 2:
req = _a.sent();
if (req.$response.error) {
return [2 /*return*/, Promise.reject({
err: req.$response.error.name,
errMessage: req.$response.error.message,
data: req.$response.error,
})];
}
if (!req.$response.data) {
return [2 /*return*/, Promise.reject({
err: 'Something went wrong!',
errMessage: 'Unknown error occured. Please try again',
data: null,
})];
}
return [2 /*return*/, Promise.resolve({
message: 'Objects listed succesfully',
data: req.$response.data,
})];
case 3:
err_1 = _a.sent();
return [2 /*return*/, Promise.reject({
err: 'Something went wrong!',
errMessage: 'Unknown error occured. Please try again',
data: err_1,
})];
case 4: return [2 /*return*/];
}
});
});
};
return ReactS3Client;
}());
exports.default = ReactS3Client;

@@ -43,2 +43,11 @@ export declare type DateISOString = string;

};
export declare type ListFileResponse = {
message: string;
data: AWS.S3.ListObjectsOutput;
};
export declare type ListFileErrorResponse = {
err: string;
errMessage: string;
data: any;
};
export {};
{
"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)",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc