Verified Commit c39de3ac authored by Chocobozzz's avatar Chocobozzz
Browse files

Correctly set original filename as source

parent bc865a34
......@@ -97,12 +97,14 @@ videosRouter.get('/:id/description',
asyncMiddleware(videosGetValidator),
asyncMiddleware(getVideoDescription)
)
videosRouter.get('/:id/source',
openapiOperationDoc({ operationId: 'getVideoSource' }),
authenticate,
asyncMiddleware(videoSourceGetValidator),
getVideoSource
)
videosRouter.get('/:id',
openapiOperationDoc({ operationId: 'getVideo' }),
optionalAuthenticate,
......
......@@ -152,7 +152,7 @@ async function addVideo (options: {
video.url = getLocalVideoActivityPubUrl(video) // We use the UUID, so set the URL after building the object
const videoFile = await buildNewFile(videoPhysicalFile)
const originalFilename = videoPhysicalFile.filename
const originalFilename = videoPhysicalFile.originalname
// Move physical file
const destination = VideoPathManager.Instance.getFSVideoFileOutputPath(video, videoFile)
......
......@@ -152,7 +152,7 @@ const videosAddResumableValidator = [
if (!await isVideoAccepted(req, res, file)) return cleanup()
res.locals.videoFileResumable = file
res.locals.videoFileResumable = { ...file, originalname: file.filename }
return next()
}
......
import { HttpStatusCode } from '@shared/models'
import { createSingleServer, PeerTubeServer, setAccessTokensToServers } from '@shared/server-commands'
import { cleanupTests, createSingleServer, PeerTubeServer, setAccessTokensToServers } from '@shared/server-commands'
describe('Test video sources API validator', function () {
let server: PeerTubeServer = null
......@@ -10,7 +10,6 @@ describe('Test video sources API validator', function () {
this.timeout(30000)
server = await createSingleServer(1)
await setAccessTokensToServers([ server ])
const created = await server.videos.quickUpload({ name: 'video' })
......@@ -38,4 +37,8 @@ describe('Test video sources API validator', function () {
it('Should succeed with the correct parameters get the source as another user', async function () {
await server.videos.getSource({ id: uuid })
})
after(async function () {
await cleanupTests([ server ])
})
})
import 'mocha'
import * as chai from 'chai'
import { createSingleServer, PeerTubeServer, setAccessTokensToServers } from '@shared/server-commands'
import { cleanupTests, createSingleServer, PeerTubeServer, setAccessTokensToServers } from '@shared/server-commands'
const expect = chai.expect
describe('Test video source', () => {
let server: PeerTubeServer = null
let uuid: string
const fixture = 'video_short.webm'
before(async function () {
......@@ -14,15 +13,27 @@ describe('Test video source', () => {
server = await createSingleServer(1)
await setAccessTokensToServers([ server ])
})
it('Should get the source filename with legacy upload', async function () {
this.timeout(30000)
const { uuid } = await server.videos.upload({ attributes: { name: 'my video', fixture }, mode: 'legacy' })
const created = await server.videos.quickUpload({ name: 'video', fixture })
uuid = created.uuid
const source = await server.videos.getSource({ id: uuid })
expect(source.filename).to.equal(fixture)
})
it('Should get the source filename', async function () {
it('Should get the source filename with resumable upload', async function () {
this.timeout(30000)
const source = await server.videos.getSource({ id: uuid, token: server.accessToken })
const { uuid } = await server.videos.upload({ attributes: { name: 'my video', fixture }, mode: 'resumable' })
const source = await server.videos.getSource({ id: uuid })
expect(source.filename).to.equal(fixture)
})
after(async function () {
await cleanupTests([ server ])
})
})
......@@ -69,7 +69,7 @@ declare module 'express' {
} | UploadFileForCheck[]
// Upload file with a duration added by our middleware
export type VideoUploadFile = Pick<Express.Multer.File, 'path' | 'filename' | 'size'> & {
export type VideoUploadFile = Pick<Express.Multer.File, 'path' | 'filename' | 'size', 'originalname'> & {
duration: number
}
......@@ -86,6 +86,7 @@ declare module 'express' {
duration: number
path: string
filename: string
originalname: string
}
// Extends Response with added functions and potential variables passed by middlewares
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment