]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - shared/extra-utils/shared/abstract-command.ts
Introduce live command
[github/Chocobozzz/PeerTube.git] / shared / extra-utils / shared / abstract-command.ts
index dd4598a9137297240d7f6171a7891061b3272dd9..38129d55903f414e8cae538624c495a3e9ea1ce5 100644 (file)
@@ -1,5 +1,5 @@
 import { HttpStatusCode } from '@shared/core-utils'
-import { makeDeleteRequest, makeGetRequest, makePostBodyRequest, makePutBodyRequest, unwrapBody, unwrapText } from '../requests/requests'
+import { makeDeleteRequest, makeGetRequest, makePostBodyRequest, makePutBodyRequest, makeUploadRequest, unwrapBody, unwrapText } from '../requests/requests'
 import { ServerInfo } from '../server/servers'
 
 export interface OverrideCommandOptions {
@@ -86,6 +86,36 @@ abstract class AbstractCommand {
     })
   }
 
+  protected postUploadRequest (options: CommonCommandOptions & {
+    fields?: { [ fieldName: string ]: any }
+    attaches?: any
+  }) {
+    const { fields, attaches } = options
+
+    return makeUploadRequest({
+      ...this.buildCommonRequestOptions(options),
+
+      method: 'POST',
+      fields,
+      attaches
+    })
+  }
+
+  protected putUploadRequest (options: CommonCommandOptions & {
+    fields?: { [ fieldName: string ]: any }
+    attaches?: any
+  }) {
+    const { fields, attaches } = options
+
+    return makeUploadRequest({
+      ...this.buildCommonRequestOptions(options),
+
+      method: 'PUT',
+      fields,
+      attaches
+    })
+  }
+
   private buildCommonRequestOptions (options: CommonCommandOptions) {
     const { token, expectedStatus, defaultExpectedStatus, path } = options