]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - shared/extra-utils/shared/abstract-command.ts
Introduce channels command
[github/Chocobozzz/PeerTube.git] / shared / extra-utils / shared / abstract-command.ts
index be368376f75d305560a9b95d01477d8134065a40..6a9ab1348d8c37b533e91085195cbb17c5c73ecf 100644 (file)
@@ -1,4 +1,6 @@
+import { isAbsolute, join } from 'path'
 import { HttpStatusCode } from '@shared/core-utils'
+import { root } from '../miscs'
 import {
   makeDeleteRequest,
   makeGetRequest,
@@ -146,6 +148,25 @@ abstract class AbstractCommand {
     })
   }
 
+  protected updateImageRequest (options: InternalCommonCommandOptions & {
+    fixture: string
+    fieldname: string
+  }) {
+    let filePath = ''
+    if (isAbsolute(options.fixture)) {
+      filePath = options.fixture
+    } else {
+      filePath = join(root(), 'server', 'tests', 'fixtures', options.fixture)
+    }
+
+    return this.postUploadRequest({
+      ...options,
+
+      fields: {},
+      attaches: { [options.fieldname]: filePath }
+    })
+  }
+
   private buildCommonRequestOptions (options: InternalCommonCommandOptions) {
     const { path } = options