So you want to create a URL to an image or video that you've uploaded to the Media Manager ?
The simplest way is to use a static URL like this:
let imageUrl =`https://static.wixstatic.com/media/${fileName}`;
Keep reading for what fileName really means.
There's a bit of confusion about getFileUrl, so let's clear some things up.
getFileURL gives you a download URL with a token.
The token will expire after 600 minutes so if you want to get to your file after 10 hours using the returned URL, this function is not for you.
The nice thing about getFileURL is that you can use it for content where you don't want to make the URL permanently available.
If you want to use the link to your file for more than 10 hours you need to regenerate the URL and token, or you can use a static link as shown above.
So what is fileName ?
fileName is not the name of the file in the UI of the Media Manager.
The fileName that you want for your URL is a unique identifier assigned by the Media Manager when you upload a file using upload() or importFile() or getFileInfo() and can be found in the objects returned by each of these functions.
If you want to see the fileName in the UI:
Open the Media Manager.
Select a file.
Click on the down arrow next to File Info.
Click Copy URL .
Do a Paste somewhere to see the static URL including the filename .
You'll get something like:
https://static.wixstatic.com/media/81c916_38c28d77469d40419732e0667200eb48~mv2.jpeg
"The nice thing about getFileURL is that you can use it for content where you don't want to make the URL permanently available"
Is there a way to get a permanent URL to a file/video/image and so on?
I would like to obtain the original file name from the fileinfo()
I was trying to do it from the front end calling the import wix-media-backend API
Then I do not know if I have to make a backend module and how to call the API from there
How canIminstall the media manager module, when I put the import
I get Cannot find module 'wix-media-backend'
OOOOOOMMMMMMMMMGGGGGGGGG This has been fixed!
Wix has just released new Media Manager APIs that allow you to get folders, files, parent folders, etc.
Check out the announcement from July 7:
I played with it a couple of days ago, and it is WONDERFUL. I am breathing a massive sigh of relief because I needed this sooooo badly.
@Yisrael (Wix) said: "This post brings world peace, solves global warming, and is a great reason to have a beer."
The July 7 announcement brings world peace, solves global warming, and is a great reason to have a beer.
Wix makes it complex for generate URL programmatically.
This does not solve my problem. It still requires that you MANUALLY open every image/file and get the URL, which you could always do. This is nothing new. I need a PROGRAMMATIC way of getting this info. As far as I can tell from this article, there is still no way to get the filename using any Wix API if the file has already been uploaded. Yes, I know I can get the URL at the time of upload, but once it's there, you cannot get it by using a totally programmatic solution. Correct?
Again, the only way I've found to get the filename without having to manually click on every single image is to multi-select every image using the Media Manager, and put them all into a single gallery. Then loop through the gallery, capture the slug, and massage it using a regexp into the filename you're looking for. It's partially automated, but still requires the manual step of creating the gallery.
I am looking for a PROGRAMMATIC way of doing this. Either by allowing me to get all files in a specific directory, or by mapping MY filename to WIX's filename programmatically.
Am I reading the above article wrong? It seems like you have to use the Media Manager to do any of this and you cannot write code to do it.
Thank you for disambiguating the naming convention of each kind of file. But it still does not solve the problem of requiring laborious manual steps to get at your file URLs.
UPDATE:
Follow the steps in this article to get your media file's URL. As stated above, fileName will be in the URL. However, each media type has a different format for the fileName string as follows: Image/GIF:
https://static.wixstatic.com/media/{22d494_cb2a8a381bb1495e9a320ae23f4fd18d~mv2.gif} Video: https://video.wixstatic.com/video/{22d494_fef6ff6f52b04b4aa1e1c0ab6d1bb194}/360p/mp4/file.mp4 Audio: https://static.wixstatic.com/mp3/{22d494_5543f167bf1c45ea984bc76e699b457b.mp3} Document:
https://8b7eef41-7fbb-440b-928a-a442878112a3.usrfiles.com/ugd/{22d494_bddbcfb54d4442a7a042a3ab81347458.pdf}
Can we get one post for documents as well?
This post brings world peace, solves global warming, and is a great reason to have a beer.