0% found this document useful (0 votes)
36 views3 pages

Subir Video Laravel

The document discusses different ways to store and retrieve images and videos in a Laravel/Vue application. It shows code for determining image/video types, generating URLs for stored media, and displaying images and videos. Methods like store(), url(), and asset() are used to upload files to storage and get file paths.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
36 views3 pages

Subir Video Laravel

The document discusses different ways to store and retrieve images and videos in a Laravel/Vue application. It shows code for determining image/video types, generating URLs for stored media, and displaying images and videos. Methods like store(), url(), and asset() are used to upload files to storage and get file paths.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 3

getProductPaginated y

getProductBySlug

var my_images =
item.pictures.length > 0
? item.pictures.map((picture, index) => {
var type =
item.mime_type.length > 0 && item.mime_type[index] != null
? item.mime_type[index]
: ''
var is_video = type.includes('video') ? true : false
var ext = type.split('/').pop()

return is_video
? `${import.meta.env.VITE_IMAGES_BASE_URL}/storage/videos/${
item.image_hash[index]
}.${ext}`
: `${
import.meta.env.VITE_IMAGES_BASE_URL
}/images/thumbs/${picture}`
})
: ''

for_video: `${
import.meta.env.VITE_IMAGES_BASE_URL
}/images/thumbs/video_preview.png`,

let type = item.mime_type[0] ?? ''


let is_video = type.includes('video') ? true : false
let ext = type.split('/').pop()

let my_image = is_video


? `${import.meta.env.VITE_IMAGES_BASE_URL}/storage/videos/${
item.image_hash[0]
}.${ext}`
: `${import.meta.env.VITE_IMAGES_BASE_URL}/images/thumbs/${
item.pictures[0]
}`

v-if="this.mime_type[selectedIndex]!='video/mp4'"
"adminv2.basterboom.loc:8043/images/thumbs/videopreview.jpg"

<video
:src="src"
:muted="muted"
:autoplay="autoplay"
:controls="controls"
:loop="loop"
:width="width"
:height="height"
:poster="poster"
:preload="preload"
:playsinline="true"
ref="player"
/>

EN VUEJS
let type = item.mime_type[0] ?? ''
let is_video = type.includes('video') ? true : false
let ext = type.split('/').pop()

let my_image = is_video


? `${import.meta.env.VITE_IMAGES_BASE_URL}/storage/videos/${
item.image_hash[0]
}.${ext}`
: `${import.meta.env.VITE_IMAGES_BASE_URL}/images/thumbs/${
item.pictures[0]
}`

EN ADMIN JAVASCRIPT
let type = image.imagen.mime_type ?? ''
let is_video = type.includes('video') ? true : false

let srcThumbs, hrefView, media


let ext = type.split('/').pop()

if (is_video) {
srcThumbs = `/images/thumbs/video_preview.png`
hrefView = `/storage/videos/${image.imagen.image_hash}.${ext}`
media = `<video width="100%" height="100%" title="${image.imagen.image_name}"
type='${ext}' controls autoplay loop muted
poster="basterboom/images/video_preview.png">
<source src="${srcThumbs}">
Your browser does not support the video tag.
</video>`
} else {
srcThumbs = `/images/thumbs/${image.imagen.image_name}`
hrefView = `/images/${image.imagen.image_name}`
media = `<img src="${srcThumbs}" class="card-img-top" title="$
{image.imagen.image_name}">`
}

$request->file('archivo')->store('public');

en mi caso
$file('archivo')->store('public');

Ahora que ya tenemos nuestro archivo guardado, podemos encontrarlo en la ruta


storage/app/public pero para poder acceder a el mediante nuestra aplicación,
debemos indicarle a laravel que queremos hacer uso de la carpeta storage, para ello
debemos ejecutar este comando:

php artisan storage:link

<img src="/storage/nombreGeneradoDeNuestaImagen.png" alt="image">

Utilizando la función store(), puedes subir imágenes a diferentes ubicaciones en el


sistema de almacenamiento, y utilizando la función url(), puedes recuperar las
imágenes subidas.

Para subir ficheros harías lo siguiente.

$request->file('my_file')->store('shared');

Para Obtener la ruta de los ficheros

$path = asset('storage/my_file.png');

You might also like