uploads.js 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. "use strict";
  2. // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
  3. var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
  4. if (k2 === undefined) k2 = k;
  5. var desc = Object.getOwnPropertyDescriptor(m, k);
  6. if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
  7. desc = { enumerable: true, get: function() { return m[k]; } };
  8. }
  9. Object.defineProperty(o, k2, desc);
  10. }) : (function(o, m, k, k2) {
  11. if (k2 === undefined) k2 = k;
  12. o[k2] = m[k];
  13. }));
  14. var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
  15. Object.defineProperty(o, "default", { enumerable: true, value: v });
  16. }) : function(o, v) {
  17. o["default"] = v;
  18. });
  19. var __importStar = (this && this.__importStar) || function (mod) {
  20. if (mod && mod.__esModule) return mod;
  21. var result = {};
  22. if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
  23. __setModuleDefault(result, mod);
  24. return result;
  25. };
  26. Object.defineProperty(exports, "__esModule", { value: true });
  27. exports.Uploads = void 0;
  28. const resource_1 = require("../../resource.js");
  29. const PartsAPI = __importStar(require("./parts.js"));
  30. const parts_1 = require("./parts.js");
  31. class Uploads extends resource_1.APIResource {
  32. constructor() {
  33. super(...arguments);
  34. this.parts = new PartsAPI.Parts(this._client);
  35. }
  36. /**
  37. * Creates an intermediate
  38. * [Upload](https://platform.openai.com/docs/api-reference/uploads/object) object
  39. * that you can add
  40. * [Parts](https://platform.openai.com/docs/api-reference/uploads/part-object) to.
  41. * Currently, an Upload can accept at most 8 GB in total and expires after an hour
  42. * after you create it.
  43. *
  44. * Once you complete the Upload, we will create a
  45. * [File](https://platform.openai.com/docs/api-reference/files/object) object that
  46. * contains all the parts you uploaded. This File is usable in the rest of our
  47. * platform as a regular File object.
  48. *
  49. * For certain `purpose` values, the correct `mime_type` must be specified. Please
  50. * refer to documentation for the
  51. * [supported MIME types for your use case](https://platform.openai.com/docs/assistants/tools/file-search#supported-files).
  52. *
  53. * For guidance on the proper filename extensions for each purpose, please follow
  54. * the documentation on
  55. * [creating a File](https://platform.openai.com/docs/api-reference/files/create).
  56. */
  57. create(body, options) {
  58. return this._client.post('/uploads', { body, ...options });
  59. }
  60. /**
  61. * Cancels the Upload. No Parts may be added after an Upload is cancelled.
  62. */
  63. cancel(uploadId, options) {
  64. return this._client.post(`/uploads/${uploadId}/cancel`, options);
  65. }
  66. /**
  67. * Completes the
  68. * [Upload](https://platform.openai.com/docs/api-reference/uploads/object).
  69. *
  70. * Within the returned Upload object, there is a nested
  71. * [File](https://platform.openai.com/docs/api-reference/files/object) object that
  72. * is ready to use in the rest of the platform.
  73. *
  74. * You can specify the order of the Parts by passing in an ordered list of the Part
  75. * IDs.
  76. *
  77. * The number of bytes uploaded upon completion must match the number of bytes
  78. * initially specified when creating the Upload object. No Parts may be added after
  79. * an Upload is completed.
  80. */
  81. complete(uploadId, body, options) {
  82. return this._client.post(`/uploads/${uploadId}/complete`, { body, ...options });
  83. }
  84. }
  85. exports.Uploads = Uploads;
  86. Uploads.Parts = parts_1.Parts;
  87. //# sourceMappingURL=uploads.js.map