mediaManager.getFileInfo(file) error

Hello,
I am trying to use MediaManager getFileInfo function to get all information for an uploaded file but is not working as described…
I have uploaded the file and got its URL (and I can access the file in a browser) , but when passing URL to mediaManager.getFileInfo(file) I get a response :
“405 Method Not Allowed
The method GET is not allowed for this resource. <br”
Does anyone have any idea why this might be ?

Thank you !
Vasil

We need more information in order to assist. What code are you using? What works, and what doesn’t?

Hello Yisrael,

I have uploaded an image and it has following url which is open and accessible from my browser (you shall be able to see it too): https://static.wixstatic.com/media/a77ba8_5725bf9f909047b4b6f6185ad873be31~mv2.jpg

Then I also have .jwt module with following code:
import { mediaManager } from ‘wix-media-backend’;
//=============================
export function getfileinfo(url) {
console.log(url);
getFileInfo(url);

}
export async function getFileInfo(file) {
var a= await mediaManager.getFileInfo(file);
console.log(a);
return a
}

From front end on button.click I call function getfileinfo(url) passing the url above defined as a variable.

And in console log i get error:
405 Method Not Allowed

405 Method Not Allowed

The method GET is not allowed for this resource .

Just let me know if any more information is needed.

Regards,

Vasil

Hello, I have the same error using GetFileInfo from a collection hook, while the input parameter is something like wix:image://v1/e50527_87c3db25ae444272911d997471cc035a~mv2.jpg/DSC_8284.jpg#originWidth=2000&originHeight=1333, i.e " As found in image type fields of database collections ", as explained in the documentation here:
https://www.wix.com/corvid/reference/wix-media-backend.mediaManager.html#getFileInfo
Any idea?
Thanks in advance

I have the exact same problem. Any help?

Hi, from what I experienced, you should not call getFileInfo() with the full URL. Try to extract the file name “a77…~mv2.jsp” (I do it with a simple regular expression) and call the method with that.
Hope it helps.
David

are you suggesting that the filename is a part of the actual url?

if so that would be helpful. Could you elaborate more on that?

As well just to say i was following the official docs, which say that getFileInfo should work with the actual url given, but it does not seem to be true.

Thanks.

@javier51884 Yes, the filename (in bold) is part of the URL:
https://static.wixstatic.com/media/ a77ba8_5725bf9f909047b4b6f6185ad873be31~mv2.jpg

I think the official doc is saying getFileInfo() should be used with " The Media Manager name or Wix URL of the file to get the information for"

From what I understood, in our case, the media manager name of the file is " a77ba8_5725bf9f909047b4b6f6185ad873be31~mv2.jpg " while the Wix URL would rather be something like the following: wix:image://v1/ e50527_9cc64ba219414afca8b8db839136b13d~mv2.jpg /dsc_4976jpg#originWidth=2000&originHeight
And a Wix URL is not an HTTP URL :wink:

In my case, I extract the file name from the WIX Url using the following regexp:
const imageFileNameRegex = new RegExp(/wix:image://v[0-9]+/([^.]+[.]jpg)/.*/)

In my use case, I need to get the real File HTTP Url, and it seems getFileUrl() only works with the file name but not with the Wix Url…unlike the doc is saying…

David.

Hi guys,

For a video it is a bit different, I have found the following
Wix URL: wix:video: //v1/06f493_a3e3597b33c6491d84b4086e14913e34/IMG_3560.mp4#posterUri=06f493_a3e3597b33c6491d84b4086e14913e53f000.jpg&posterWidth=656&posterHeight=1080
Filename: 06f493_a3e3597b33c6491d84b4086e14913e34

What would be the regExp, and how to apply it? (the code needed to convert the URL to the filename wasn’t mentioned in previous answer)