uploads.js 2.9 KB

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