uploads.mjs 2.6 KB

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