serverless-simple-middleware 0.0.57 → 0.0.58
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/aws/simple.d.ts +1 -0
- package/dist/aws/simple.js +20 -0
- package/package.json +1 -1
- package/src/aws/simple.ts +17 -0
package/dist/aws/simple.d.ts
CHANGED
|
@@ -25,6 +25,7 @@ export declare class SimpleAWS {
|
|
|
25
25
|
readFile: (bucket: string, key: string) => Promise<string>;
|
|
26
26
|
readFileBuffer: (bucket: string, key: string) => Promise<Buffer>;
|
|
27
27
|
upload: (bucket: string, localPath: string, key: string) => Promise<string>;
|
|
28
|
+
uploadFromBuffer: (bucket: string, key: string, buffer: Buffer) => Promise<string>;
|
|
28
29
|
writeFile: (bucket: string, key: string, content: string) => Promise<void>;
|
|
29
30
|
getSignedUrl: (bucketName: string, key: string, operation?: "getObject" | "putObject", params?: S3SignedUrlParams | undefined) => S3SignedUrlResult;
|
|
30
31
|
getSignedCookie: (keyPairId: string, privateKey: string, url: string, expires: number) => AWS.CloudFront.Signer.CustomPolicy;
|
package/dist/aws/simple.js
CHANGED
|
@@ -381,6 +381,26 @@ var SimpleAWS = /** @class */ (function () {
|
|
|
381
381
|
}
|
|
382
382
|
});
|
|
383
383
|
}); };
|
|
384
|
+
this.uploadFromBuffer = function (bucket, key, buffer) { return __awaiter(_this, void 0, void 0, function () {
|
|
385
|
+
var putResult;
|
|
386
|
+
return __generator(this, function (_a) {
|
|
387
|
+
switch (_a.label) {
|
|
388
|
+
case 0:
|
|
389
|
+
logger.debug("Upload item[" + key + "] into bucket[" + bucket + "]");
|
|
390
|
+
return [4 /*yield*/, this.s3
|
|
391
|
+
.upload({
|
|
392
|
+
Bucket: bucket,
|
|
393
|
+
Key: key,
|
|
394
|
+
Body: buffer,
|
|
395
|
+
})
|
|
396
|
+
.promise()];
|
|
397
|
+
case 1:
|
|
398
|
+
putResult = _a.sent();
|
|
399
|
+
logger.stupid("putResult", putResult);
|
|
400
|
+
return [2 /*return*/, key];
|
|
401
|
+
}
|
|
402
|
+
});
|
|
403
|
+
}); };
|
|
384
404
|
this.writeFile = function (bucket, key, content) { return __awaiter(_this, void 0, void 0, function () {
|
|
385
405
|
var tempFile;
|
|
386
406
|
return __generator(this, function (_a) {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "serverless-simple-middleware",
|
|
3
3
|
"description": "Simple middleware to translate the interface of lambda's handler to request => response",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.58",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
7
|
"author": "VoyagerX",
|
package/src/aws/simple.ts
CHANGED
|
@@ -313,6 +313,23 @@ export class SimpleAWS {
|
|
|
313
313
|
return key;
|
|
314
314
|
};
|
|
315
315
|
|
|
316
|
+
public uploadFromBuffer = async (
|
|
317
|
+
bucket: string,
|
|
318
|
+
key: string,
|
|
319
|
+
buffer: Buffer,
|
|
320
|
+
): Promise<string> => {
|
|
321
|
+
logger.debug(`Upload item[${key}] into bucket[${bucket}]`);
|
|
322
|
+
const putResult = await this.s3
|
|
323
|
+
.upload({
|
|
324
|
+
Bucket: bucket,
|
|
325
|
+
Key: key,
|
|
326
|
+
Body: buffer,
|
|
327
|
+
})
|
|
328
|
+
.promise();
|
|
329
|
+
logger.stupid(`putResult`, putResult);
|
|
330
|
+
return key;
|
|
331
|
+
};
|
|
332
|
+
|
|
316
333
|
public writeFile = async (
|
|
317
334
|
bucket: string,
|
|
318
335
|
key: string,
|