download.js 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.Download = void 0;
  6. /**
  7. * Copyright (c) Microsoft Corporation.
  8. *
  9. * Licensed under the Apache License, Version 2.0 (the "License");
  10. * you may not use this file except in compliance with the License.
  11. * You may obtain a copy of the License at
  12. *
  13. * http://www.apache.org/licenses/LICENSE-2.0
  14. *
  15. * Unless required by applicable law or agreed to in writing, software
  16. * distributed under the License is distributed on an "AS IS" BASIS,
  17. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  18. * See the License for the specific language governing permissions and
  19. * limitations under the License.
  20. */
  21. class Download {
  22. constructor(page, url, suggestedFilename, artifact) {
  23. this._page = void 0;
  24. this._url = void 0;
  25. this._suggestedFilename = void 0;
  26. this._artifact = void 0;
  27. this._page = page;
  28. this._url = url;
  29. this._suggestedFilename = suggestedFilename;
  30. this._artifact = artifact;
  31. }
  32. page() {
  33. return this._page;
  34. }
  35. url() {
  36. return this._url;
  37. }
  38. suggestedFilename() {
  39. return this._suggestedFilename;
  40. }
  41. async path() {
  42. return await this._artifact.pathAfterFinished();
  43. }
  44. async saveAs(path) {
  45. return await this._artifact.saveAs(path);
  46. }
  47. async failure() {
  48. return await this._artifact.failure();
  49. }
  50. async createReadStream() {
  51. return await this._artifact.createReadStream();
  52. }
  53. async cancel() {
  54. return await this._artifact.cancel();
  55. }
  56. async delete() {
  57. return await this._artifact.delete();
  58. }
  59. }
  60. exports.Download = Download;