uploads.mjs 2.6 KB

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