store asset content type in db, add video support

Signed-off-by: Nicolas Froger <nicolas@kektus.xyz>
This commit is contained in:
Nicolas Froger 2024-07-27 02:47:56 +02:00
commit 25b6dbcd7e
No known key found for this signature in database
13 changed files with 56 additions and 26 deletions

View file

@ -62,7 +62,18 @@ function postDataToggle() {
<img
class="absolute top-0 left-0 w-full h-full object-cover -z-10"
:data-src="asset.presignedUrl"
v-if="asset.contentType.startsWith('image/')"
/>
<video
class="absolute top-0 left-0 w-full h-full object-cover -z-10"
loop
muted="true"
playsinline
data-autoplay
v-else
>
<source :src="asset.presignedUrl" :type="asset.contentType" />
</video>
<div
class="grid grid-cols-3 grid-rows-5 absolute w-full h-full top-0 left-0 pointer-events-none"
>

View file

@ -28,7 +28,7 @@ export const useAdminPostsStore = defineStore('adminPosts', () => {
'Content-Type': 'application/json',
'X-admin-token': authStore.adminToken
},
body: JSON.stringify({ filename: file.file.name })
body: JSON.stringify({ filename: file.file.name, contentType: file.file.type })
})
.catch((e) => {
console.log('Contact API asset failed: ' + e)

View file

@ -215,6 +215,9 @@ function updateCityAndCountry() {
<Card>
<CardContent class="flex aspect-square items-center justify-center p-6">
<img :src="file.displayUrl" v-if="file.file.type.startsWith('image/')" />
<video controls v-else>
<source :src="file.displayUrl" :type="file.file.type" />
</video>
</CardContent>
</Card>
<div class="grid grid-cols-2 justify-items-center mt-2">

View file

@ -225,7 +225,10 @@ function removeAsset(id) {
<div class="flex flex-col">
<Card>
<CardContent class="flex aspect-square items-center justify-center p-6">
<img :src="asset.presignedUrl" />
<img :src="asset.presignedUrl" v-if="asset.contentType.startsWith('image/')" />
<video controls v-else>
<source :src="asset.presignedUrl" :type="asset.contentType" />
</video>
</CardContent>
</Card>
<div class="grid justify-items-center mt-2">
@ -244,6 +247,9 @@ function removeAsset(id) {
<Card>
<CardContent class="flex aspect-square items-center justify-center p-6">
<img :src="file.displayUrl" v-if="file.file.type.startsWith('image/')" />
<video controls v-else>
<source :src="file.displayUrl" :type="file.file.type" />
</video>
</CardContent>
</Card>
<div class="grid grid-cols-2 justify-items-center mt-2">