This commit is contained in:
Caleb Gosiak 2021-09-30 15:52:51 -05:00
parent d9e985924e
commit 2377d067bc
4 changed files with 31 additions and 46 deletions

14
dist/restore/index.js vendored
View file

@ -43330,20 +43330,14 @@ class CacheService {
uploadToS3(key, archivePath) {
return __awaiter(this, void 0, void 0, function* () {
const client = new aws_sdk_1.S3();
// Read in the file, convert it to base64, store to S3
fs_1.default.readFile(archivePath, (err, data) => {
if (err) {
throw err;
}
const base64data = data.toString("base64");
client
const data = fs_1.default.readFileSync(archivePath).toString("base64");
return client
.putObject({
Bucket: this._bucket,
Key: key,
Body: base64data
Body: data
})
.send();
});
.promise();
});
}
}

14
dist/save/index.js vendored
View file

@ -43330,20 +43330,14 @@ class CacheService {
uploadToS3(key, archivePath) {
return __awaiter(this, void 0, void 0, function* () {
const client = new aws_sdk_1.S3();
// Read in the file, convert it to base64, store to S3
fs_1.default.readFile(archivePath, (err, data) => {
if (err) {
throw err;
}
const base64data = data.toString("base64");
client
const data = fs_1.default.readFileSync(archivePath).toString("base64");
return client
.putObject({
Bucket: this._bucket,
Key: key,
Body: base64data
Body: data
})
.send();
});
.promise();
});
}
}

View file

@ -1,6 +1,6 @@
{
"name": "cache",
"version": "0.2.0",
"version": "0.3.0",
"private": true,
"description": "Cache dependencies and build outputs",
"main": "dist/restore/index.js",

View file

@ -1,7 +1,8 @@
import * as utils from "@actions/cache/lib/internal/cacheUtils";
import { createTar, listTar } from "@actions/cache/lib/internal/tar";
import * as core from "@actions/core";
import { S3 } from "aws-sdk";
import { AWSError, S3 } from "aws-sdk";
import { PromiseResult } from "aws-sdk/lib/request";
import filesize from "filesize";
import fs from "fs";
import * as path from "path";
@ -73,23 +74,19 @@ export class CacheService {
return key;
}
private async uploadToS3(key: string, archivePath: string): Promise<void> {
private async uploadToS3(
key: string,
archivePath: string
): Promise<PromiseResult<S3.PutObjectOutput, AWSError>> {
const client = new S3();
// Read in the file, convert it to base64, store to S3
fs.readFile(archivePath, (err, data) => {
if (err) {
throw err;
}
const data = fs.readFileSync(archivePath).toString("base64");
const base64data = data.toString("base64");
client
return client
.putObject({
Bucket: this._bucket,
Key: key,
Body: base64data
Body: data
})
.send();
});
.promise();
}
}