@actions/artifact 0.5.0 → 0.6.1
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/LICENSE.md +8 -8
- package/README.md +213 -213
- package/lib/artifact-client.d.ts +10 -10
- package/lib/artifact-client.js +10 -10
- package/lib/internal/artifact-client.d.ts +41 -41
- package/lib/internal/artifact-client.js +164 -148
- package/lib/internal/artifact-client.js.map +1 -1
- package/lib/internal/config-variables.d.ts +11 -11
- package/lib/internal/config-variables.js +70 -70
- package/lib/internal/contracts.d.ts +67 -57
- package/lib/internal/contracts.js +2 -2
- package/lib/internal/download-http-client.d.ts +39 -39
- package/lib/internal/download-http-client.js +271 -274
- package/lib/internal/download-http-client.js.map +1 -1
- package/lib/internal/download-options.d.ts +7 -7
- package/lib/internal/download-options.js +2 -2
- package/lib/internal/download-response.d.ts +10 -10
- package/lib/internal/download-response.js +2 -2
- package/lib/internal/download-specification.d.ts +19 -19
- package/lib/internal/download-specification.js +60 -60
- package/lib/internal/http-manager.d.ts +12 -12
- package/lib/internal/http-manager.js +30 -30
- package/lib/internal/path-and-artifact-name-validation.d.ts +8 -0
- package/lib/internal/path-and-artifact-name-validation.js +66 -0
- package/lib/internal/path-and-artifact-name-validation.js.map +1 -0
- package/lib/internal/requestUtils.d.ts +3 -3
- package/lib/internal/requestUtils.js +74 -74
- package/lib/internal/status-reporter.d.ts +21 -22
- package/lib/internal/status-reporter.js +50 -63
- package/lib/internal/status-reporter.js.map +1 -1
- package/lib/internal/upload-gzip.d.ts +14 -14
- package/lib/internal/upload-gzip.js +107 -88
- package/lib/internal/upload-gzip.js.map +1 -1
- package/lib/internal/upload-http-client.d.ts +48 -48
- package/lib/internal/upload-http-client.js +393 -378
- package/lib/internal/upload-http-client.js.map +1 -1
- package/lib/internal/upload-options.d.ts +34 -34
- package/lib/internal/upload-options.js +2 -2
- package/lib/internal/upload-response.d.ts +19 -19
- package/lib/internal/upload-response.js +2 -2
- package/lib/internal/upload-specification.d.ts +11 -11
- package/lib/internal/upload-specification.js +87 -87
- package/lib/internal/upload-specification.js.map +1 -1
- package/lib/internal/utils.d.ts +66 -74
- package/lib/internal/utils.js +262 -303
- package/lib/internal/utils.js.map +1 -1
- package/package.json +49 -49
|
@@ -1,64 +1,51 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const core_1 = require("@actions/core");
|
|
4
|
-
/**
|
|
5
|
-
* Status Reporter that displays information about the progress/status of an artifact that is being uploaded or downloaded
|
|
6
|
-
*
|
|
7
|
-
* Variable display time that can be adjusted using the displayFrequencyInMilliseconds variable
|
|
8
|
-
* The total status of the upload/download gets displayed according to this value
|
|
9
|
-
* If there is a large file that is being uploaded, extra information about the individual status can also be displayed using the updateLargeFileStatus function
|
|
10
|
-
*/
|
|
11
|
-
class StatusReporter {
|
|
12
|
-
constructor(displayFrequencyInMilliseconds) {
|
|
13
|
-
this.totalNumberOfFilesToProcess = 0;
|
|
14
|
-
this.processedCount = 0;
|
|
15
|
-
this.largeFiles = new Map();
|
|
16
|
-
this.totalFileStatus = undefined;
|
|
17
|
-
this.
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
this.
|
|
22
|
-
}
|
|
23
|
-
start() {
|
|
24
|
-
// displays information about the total upload/download status
|
|
25
|
-
this.totalFileStatus = setInterval(() => {
|
|
26
|
-
// display 1 decimal place without any rounding
|
|
27
|
-
const percentage = this.formatPercentage(this.processedCount, this.totalNumberOfFilesToProcess);
|
|
28
|
-
core_1.info(`Total file count: ${this.totalNumberOfFilesToProcess} ---- Processed file #${this.processedCount} (${percentage.slice(0, percentage.indexOf('.') + 2)}%)`);
|
|
29
|
-
}, this.displayFrequencyInMilliseconds);
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
if (this.largeFileStatus) {
|
|
52
|
-
clearInterval(this.largeFileStatus);
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
incrementProcessedCount() {
|
|
56
|
-
this.processedCount++;
|
|
57
|
-
}
|
|
58
|
-
formatPercentage(numerator, denominator) {
|
|
59
|
-
// toFixed() rounds, so use extra precision to display accurate information even though 4 decimal places are not displayed
|
|
60
|
-
return ((numerator / denominator) * 100).toFixed(4).toString();
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
exports.StatusReporter = StatusReporter;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const core_1 = require("@actions/core");
|
|
4
|
+
/**
|
|
5
|
+
* Status Reporter that displays information about the progress/status of an artifact that is being uploaded or downloaded
|
|
6
|
+
*
|
|
7
|
+
* Variable display time that can be adjusted using the displayFrequencyInMilliseconds variable
|
|
8
|
+
* The total status of the upload/download gets displayed according to this value
|
|
9
|
+
* If there is a large file that is being uploaded, extra information about the individual status can also be displayed using the updateLargeFileStatus function
|
|
10
|
+
*/
|
|
11
|
+
class StatusReporter {
|
|
12
|
+
constructor(displayFrequencyInMilliseconds) {
|
|
13
|
+
this.totalNumberOfFilesToProcess = 0;
|
|
14
|
+
this.processedCount = 0;
|
|
15
|
+
this.largeFiles = new Map();
|
|
16
|
+
this.totalFileStatus = undefined;
|
|
17
|
+
this.displayFrequencyInMilliseconds = displayFrequencyInMilliseconds;
|
|
18
|
+
}
|
|
19
|
+
setTotalNumberOfFilesToProcess(fileTotal) {
|
|
20
|
+
this.totalNumberOfFilesToProcess = fileTotal;
|
|
21
|
+
this.processedCount = 0;
|
|
22
|
+
}
|
|
23
|
+
start() {
|
|
24
|
+
// displays information about the total upload/download status
|
|
25
|
+
this.totalFileStatus = setInterval(() => {
|
|
26
|
+
// display 1 decimal place without any rounding
|
|
27
|
+
const percentage = this.formatPercentage(this.processedCount, this.totalNumberOfFilesToProcess);
|
|
28
|
+
core_1.info(`Total file count: ${this.totalNumberOfFilesToProcess} ---- Processed file #${this.processedCount} (${percentage.slice(0, percentage.indexOf('.') + 2)}%)`);
|
|
29
|
+
}, this.displayFrequencyInMilliseconds);
|
|
30
|
+
}
|
|
31
|
+
// if there is a large file that is being uploaded in chunks, this is used to display extra information about the status of the upload
|
|
32
|
+
updateLargeFileStatus(fileName, chunkStartIndex, chunkEndIndex, totalUploadFileSize) {
|
|
33
|
+
// display 1 decimal place without any rounding
|
|
34
|
+
const percentage = this.formatPercentage(chunkEndIndex, totalUploadFileSize);
|
|
35
|
+
core_1.info(`Uploaded ${fileName} (${percentage.slice(0, percentage.indexOf('.') + 2)}%) bytes ${chunkStartIndex}:${chunkEndIndex}`);
|
|
36
|
+
}
|
|
37
|
+
stop() {
|
|
38
|
+
if (this.totalFileStatus) {
|
|
39
|
+
clearInterval(this.totalFileStatus);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
incrementProcessedCount() {
|
|
43
|
+
this.processedCount++;
|
|
44
|
+
}
|
|
45
|
+
formatPercentage(numerator, denominator) {
|
|
46
|
+
// toFixed() rounds, so use extra precision to display accurate information even though 4 decimal places are not displayed
|
|
47
|
+
return ((numerator / denominator) * 100).toFixed(4).toString();
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
exports.StatusReporter = StatusReporter;
|
|
64
51
|
//# sourceMappingURL=status-reporter.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"status-reporter.js","sourceRoot":"","sources":["../../src/internal/status-reporter.ts"],"names":[],"mappings":";;AAAA,wCAAkC;AAElC;;;;;;GAMG;AAEH,MAAa,cAAc;
|
|
1
|
+
{"version":3,"file":"status-reporter.js","sourceRoot":"","sources":["../../src/internal/status-reporter.ts"],"names":[],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AAI;QACF,IAAI,IAAI,CAAC,eAAe,EAAE;YACxB,aAAa,CAAC,IAAI,CAAC,eAAe,CAAC,CAAA;SACpC;IACH,CAAC;IAED,uBAAuB;QACrB,IAAI,CAAC,cAAc,EAAE,CAAA;IACvB,CAAC;IAEO,gBAAgB,CAAC,SAAiB,EAAE,WAAmB;QAC7D,0HAA0H;QAC1H,OAAO,CAAC,CAAC,SAAS,GAAG,WAAW,CAAC,GAAG,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAA;IAChE,CAAC;CACF;AAnED,wCAmEC"}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
/**
|
|
3
|
-
* Creates a Gzip compressed file of an original file at the provided temporary filepath location
|
|
4
|
-
* @param {string} originalFilePath filepath of whatever will be compressed. The original file will be unmodified
|
|
5
|
-
* @param {string} tempFilePath the location of where the Gzip file will be created
|
|
6
|
-
* @returns the size of gzip file that gets created
|
|
7
|
-
*/
|
|
8
|
-
export declare function createGZipFileOnDisk(originalFilePath: string, tempFilePath: string): Promise<number>;
|
|
9
|
-
/**
|
|
10
|
-
* Creates a GZip file in memory using a buffer. Should be used for smaller files to reduce disk I/O
|
|
11
|
-
* @param originalFilePath the path to the original file that is being GZipped
|
|
12
|
-
* @returns a buffer with the GZip file
|
|
13
|
-
*/
|
|
14
|
-
export declare function createGZipFileInBuffer(originalFilePath: string): Promise<Buffer>;
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
/**
|
|
3
|
+
* Creates a Gzip compressed file of an original file at the provided temporary filepath location
|
|
4
|
+
* @param {string} originalFilePath filepath of whatever will be compressed. The original file will be unmodified
|
|
5
|
+
* @param {string} tempFilePath the location of where the Gzip file will be created
|
|
6
|
+
* @returns the size of gzip file that gets created
|
|
7
|
+
*/
|
|
8
|
+
export declare function createGZipFileOnDisk(originalFilePath: string, tempFilePath: string): Promise<number>;
|
|
9
|
+
/**
|
|
10
|
+
* Creates a GZip file in memory using a buffer. Should be used for smaller files to reduce disk I/O
|
|
11
|
+
* @param originalFilePath the path to the original file that is being GZipped
|
|
12
|
+
* @returns a buffer with the GZip file
|
|
13
|
+
*/
|
|
14
|
+
export declare function createGZipFileInBuffer(originalFilePath: string): Promise<Buffer>;
|
|
@@ -1,89 +1,108 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __asyncValues = (this && this.__asyncValues) || function (o) {
|
|
12
|
-
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
13
|
-
var m = o[Symbol.asyncIterator], i;
|
|
14
|
-
return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
|
|
15
|
-
function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
|
|
16
|
-
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
|
|
17
|
-
};
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
|
22
|
-
result["default"] = mod;
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
const fs = __importStar(require("fs"));
|
|
27
|
-
const zlib = __importStar(require("zlib"));
|
|
28
|
-
const util_1 = require("util");
|
|
29
|
-
const stat = util_1.promisify(fs.stat);
|
|
30
|
-
/**
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
function
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __asyncValues = (this && this.__asyncValues) || function (o) {
|
|
12
|
+
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
13
|
+
var m = o[Symbol.asyncIterator], i;
|
|
14
|
+
return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
|
|
15
|
+
function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
|
|
16
|
+
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
|
|
17
|
+
};
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
|
22
|
+
result["default"] = mod;
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
const fs = __importStar(require("fs"));
|
|
27
|
+
const zlib = __importStar(require("zlib"));
|
|
28
|
+
const util_1 = require("util");
|
|
29
|
+
const stat = util_1.promisify(fs.stat);
|
|
30
|
+
/**
|
|
31
|
+
* GZipping certain files that are already compressed will likely not yield further size reductions. Creating large temporary gzip
|
|
32
|
+
* files then will just waste a lot of time before ultimately being discarded (especially for very large files).
|
|
33
|
+
* If any of these types of files are encountered then on-disk gzip creation will be skipped and the original file will be uploaded as-is
|
|
34
|
+
*/
|
|
35
|
+
const gzipExemptFileExtensions = [
|
|
36
|
+
'.gzip',
|
|
37
|
+
'.zip',
|
|
38
|
+
'.tar.lz',
|
|
39
|
+
'.tar.gz',
|
|
40
|
+
'.tar.bz2',
|
|
41
|
+
'.7z'
|
|
42
|
+
];
|
|
43
|
+
/**
|
|
44
|
+
* Creates a Gzip compressed file of an original file at the provided temporary filepath location
|
|
45
|
+
* @param {string} originalFilePath filepath of whatever will be compressed. The original file will be unmodified
|
|
46
|
+
* @param {string} tempFilePath the location of where the Gzip file will be created
|
|
47
|
+
* @returns the size of gzip file that gets created
|
|
48
|
+
*/
|
|
49
|
+
function createGZipFileOnDisk(originalFilePath, tempFilePath) {
|
|
50
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
51
|
+
for (const gzipExemptExtension of gzipExemptFileExtensions) {
|
|
52
|
+
if (originalFilePath.endsWith(gzipExemptExtension)) {
|
|
53
|
+
// return a really large number so that the original file gets uploaded
|
|
54
|
+
return Number.MAX_SAFE_INTEGER;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
return new Promise((resolve, reject) => {
|
|
58
|
+
const inputStream = fs.createReadStream(originalFilePath);
|
|
59
|
+
const gzip = zlib.createGzip();
|
|
60
|
+
const outputStream = fs.createWriteStream(tempFilePath);
|
|
61
|
+
inputStream.pipe(gzip).pipe(outputStream);
|
|
62
|
+
outputStream.on('finish', () => __awaiter(this, void 0, void 0, function* () {
|
|
63
|
+
// wait for stream to finish before calculating the size which is needed as part of the Content-Length header when starting an upload
|
|
64
|
+
const size = (yield stat(tempFilePath)).size;
|
|
65
|
+
resolve(size);
|
|
66
|
+
}));
|
|
67
|
+
outputStream.on('error', error => {
|
|
68
|
+
// eslint-disable-next-line no-console
|
|
69
|
+
console.log(error);
|
|
70
|
+
reject;
|
|
71
|
+
});
|
|
72
|
+
});
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
exports.createGZipFileOnDisk = createGZipFileOnDisk;
|
|
76
|
+
/**
|
|
77
|
+
* Creates a GZip file in memory using a buffer. Should be used for smaller files to reduce disk I/O
|
|
78
|
+
* @param originalFilePath the path to the original file that is being GZipped
|
|
79
|
+
* @returns a buffer with the GZip file
|
|
80
|
+
*/
|
|
81
|
+
function createGZipFileInBuffer(originalFilePath) {
|
|
82
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
83
|
+
return new Promise((resolve) => __awaiter(this, void 0, void 0, function* () {
|
|
84
|
+
var e_1, _a;
|
|
85
|
+
const inputStream = fs.createReadStream(originalFilePath);
|
|
86
|
+
const gzip = zlib.createGzip();
|
|
87
|
+
inputStream.pipe(gzip);
|
|
88
|
+
// read stream into buffer, using experimental async iterators see https://github.com/nodejs/readable-stream/issues/403#issuecomment-479069043
|
|
89
|
+
const chunks = [];
|
|
90
|
+
try {
|
|
91
|
+
for (var gzip_1 = __asyncValues(gzip), gzip_1_1; gzip_1_1 = yield gzip_1.next(), !gzip_1_1.done;) {
|
|
92
|
+
const chunk = gzip_1_1.value;
|
|
93
|
+
chunks.push(chunk);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
97
|
+
finally {
|
|
98
|
+
try {
|
|
99
|
+
if (gzip_1_1 && !gzip_1_1.done && (_a = gzip_1.return)) yield _a.call(gzip_1);
|
|
100
|
+
}
|
|
101
|
+
finally { if (e_1) throw e_1.error; }
|
|
102
|
+
}
|
|
103
|
+
resolve(Buffer.concat(chunks));
|
|
104
|
+
}));
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
exports.createGZipFileInBuffer = createGZipFileInBuffer;
|
|
89
108
|
//# sourceMappingURL=upload-gzip.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"upload-gzip.js","sourceRoot":"","sources":["../../src/internal/upload-gzip.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAAwB;AACxB,2CAA4B;AAC5B,+BAA8B;AAC9B,MAAM,IAAI,GAAG,gBAAS,C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AC,UAAU,EAAE,CAAA;YAC9B,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;YACtB,8IAA8I;YAC9I,MAAM,MAAM,GAAG,EAAE,CAAA;;gBACjB,KAA0B,IAAA,SAAA,cAAA,IAAI,CAAA,UAAA;oBAAnB,MAAM,KAAK,iBAAA,CAAA;oBACpB,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;iBACnB;;;;;;;;;YACD,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAA;QAChC,CAAC,CAAA,CAAC,CAAA;IACJ,CAAC;CAAA;AAdD,wDAcC"}
|
|
@@ -1,48 +1,48 @@
|
|
|
1
|
-
import { ArtifactResponse, UploadResults } from './contracts';
|
|
2
|
-
import { UploadSpecification } from './upload-specification';
|
|
3
|
-
import { UploadOptions } from './upload-options';
|
|
4
|
-
export declare class UploadHttpClient {
|
|
5
|
-
private uploadHttpManager;
|
|
6
|
-
private statusReporter;
|
|
7
|
-
constructor();
|
|
8
|
-
/**
|
|
9
|
-
* Creates a file container for the new artifact in the remote blob storage/file service
|
|
10
|
-
* @param {string} artifactName Name of the artifact being created
|
|
11
|
-
* @returns The response from the Artifact Service if the file container was successfully created
|
|
12
|
-
*/
|
|
13
|
-
createArtifactInFileContainer(artifactName: string, options?: UploadOptions | undefined): Promise<ArtifactResponse>;
|
|
14
|
-
/**
|
|
15
|
-
* Concurrently upload all of the files in chunks
|
|
16
|
-
* @param {string} uploadUrl Base Url for the artifact that was created
|
|
17
|
-
* @param {SearchResult[]} filesToUpload A list of information about the files being uploaded
|
|
18
|
-
* @returns The size of all the files uploaded in bytes
|
|
19
|
-
*/
|
|
20
|
-
uploadArtifactToFileContainer(uploadUrl: string, filesToUpload: UploadSpecification[], options?: UploadOptions): Promise<UploadResults>;
|
|
21
|
-
/**
|
|
22
|
-
* Asynchronously uploads a file. The file is compressed and uploaded using GZip if it is determined to save space.
|
|
23
|
-
* If the upload file is bigger than the max chunk size it will be uploaded via multiple calls
|
|
24
|
-
* @param {number} httpClientIndex The index of the httpClient that is being used to make all of the calls
|
|
25
|
-
* @param {UploadFileParameters} parameters Information about the file that needs to be uploaded
|
|
26
|
-
* @returns The size of the file that was uploaded in bytes along with any failed uploads
|
|
27
|
-
*/
|
|
28
|
-
private uploadFileAsync;
|
|
29
|
-
/**
|
|
30
|
-
* Uploads a chunk of an individual file to the specified resourceUrl. If the upload fails and the status code
|
|
31
|
-
* indicates a retryable status, we try to upload the chunk as well
|
|
32
|
-
* @param {number} httpClientIndex The index of the httpClient being used to make all the necessary calls
|
|
33
|
-
* @param {string} resourceUrl Url of the resource that the chunk will be uploaded to
|
|
34
|
-
* @param {NodeJS.ReadableStream} openStream Stream of the file that will be uploaded
|
|
35
|
-
* @param {number} start Starting byte index of file that the chunk belongs to
|
|
36
|
-
* @param {number} end Ending byte index of file that the chunk belongs to
|
|
37
|
-
* @param {number} uploadFileSize Total size of the file in bytes that is being uploaded
|
|
38
|
-
* @param {boolean} isGzip Denotes if we are uploading a Gzip compressed stream
|
|
39
|
-
* @param {number} totalFileSize Original total size of the file that is being uploaded
|
|
40
|
-
* @returns if the chunk was successfully uploaded
|
|
41
|
-
*/
|
|
42
|
-
private uploadChunk;
|
|
43
|
-
/**
|
|
44
|
-
* Updates the size of the artifact from -1 which was initially set when the container was first created for the artifact.
|
|
45
|
-
* Updating the size indicates that we are done uploading all the contents of the artifact
|
|
46
|
-
*/
|
|
47
|
-
patchArtifactSize(size: number, artifactName: string): Promise<void>;
|
|
48
|
-
}
|
|
1
|
+
import { ArtifactResponse, UploadResults } from './contracts';
|
|
2
|
+
import { UploadSpecification } from './upload-specification';
|
|
3
|
+
import { UploadOptions } from './upload-options';
|
|
4
|
+
export declare class UploadHttpClient {
|
|
5
|
+
private uploadHttpManager;
|
|
6
|
+
private statusReporter;
|
|
7
|
+
constructor();
|
|
8
|
+
/**
|
|
9
|
+
* Creates a file container for the new artifact in the remote blob storage/file service
|
|
10
|
+
* @param {string} artifactName Name of the artifact being created
|
|
11
|
+
* @returns The response from the Artifact Service if the file container was successfully created
|
|
12
|
+
*/
|
|
13
|
+
createArtifactInFileContainer(artifactName: string, options?: UploadOptions | undefined): Promise<ArtifactResponse>;
|
|
14
|
+
/**
|
|
15
|
+
* Concurrently upload all of the files in chunks
|
|
16
|
+
* @param {string} uploadUrl Base Url for the artifact that was created
|
|
17
|
+
* @param {SearchResult[]} filesToUpload A list of information about the files being uploaded
|
|
18
|
+
* @returns The size of all the files uploaded in bytes
|
|
19
|
+
*/
|
|
20
|
+
uploadArtifactToFileContainer(uploadUrl: string, filesToUpload: UploadSpecification[], options?: UploadOptions): Promise<UploadResults>;
|
|
21
|
+
/**
|
|
22
|
+
* Asynchronously uploads a file. The file is compressed and uploaded using GZip if it is determined to save space.
|
|
23
|
+
* If the upload file is bigger than the max chunk size it will be uploaded via multiple calls
|
|
24
|
+
* @param {number} httpClientIndex The index of the httpClient that is being used to make all of the calls
|
|
25
|
+
* @param {UploadFileParameters} parameters Information about the file that needs to be uploaded
|
|
26
|
+
* @returns The size of the file that was uploaded in bytes along with any failed uploads
|
|
27
|
+
*/
|
|
28
|
+
private uploadFileAsync;
|
|
29
|
+
/**
|
|
30
|
+
* Uploads a chunk of an individual file to the specified resourceUrl. If the upload fails and the status code
|
|
31
|
+
* indicates a retryable status, we try to upload the chunk as well
|
|
32
|
+
* @param {number} httpClientIndex The index of the httpClient being used to make all the necessary calls
|
|
33
|
+
* @param {string} resourceUrl Url of the resource that the chunk will be uploaded to
|
|
34
|
+
* @param {NodeJS.ReadableStream} openStream Stream of the file that will be uploaded
|
|
35
|
+
* @param {number} start Starting byte index of file that the chunk belongs to
|
|
36
|
+
* @param {number} end Ending byte index of file that the chunk belongs to
|
|
37
|
+
* @param {number} uploadFileSize Total size of the file in bytes that is being uploaded
|
|
38
|
+
* @param {boolean} isGzip Denotes if we are uploading a Gzip compressed stream
|
|
39
|
+
* @param {number} totalFileSize Original total size of the file that is being uploaded
|
|
40
|
+
* @returns if the chunk was successfully uploaded
|
|
41
|
+
*/
|
|
42
|
+
private uploadChunk;
|
|
43
|
+
/**
|
|
44
|
+
* Updates the size of the artifact from -1 which was initially set when the container was first created for the artifact.
|
|
45
|
+
* Updating the size indicates that we are done uploading all the contents of the artifact
|
|
46
|
+
*/
|
|
47
|
+
patchArtifactSize(size: number, artifactName: string): Promise<void>;
|
|
48
|
+
}
|