wixData.query("Media/FileshareFiles") works but mediaManager.getFileInfo(fileName) can't find the files.

I have exposed these two functions, queryMedia and fileInfo in http-functions.js (see listing at end)

https://www.navitasvs.com/_functions-dev/queryMedia shows I have a file testfile.zip.
{“items”:[{“_id”:“b1bf050b-24f5-4864-95dc-fb9dd8e6be9e”,“name”:“testfile.zip”,“_owner”:“07147f53-3dfa-43ca-b956-14de47bffd72”,“_createdDate”:{“$date”:“2020-01-03T16:09:41.608Z”},“parentFolder”:null,“path”:[{“id”:“42e7107e-ee28-43fd-b4ed-9e0cae1ac964”,“name”:“/”}],“favoriteCount”:0,“favorite”:false,“viewCount”:0,“viewed”:false,“extension”:“zip”,“size”:169250}

I can login and manually download if from https://www.navitasvs.com/file-share

But, https://www.navitasvs.com/_functions-dev/fileInfo?fileName=testfile.zip gives this error:
{“fileUrl”:{“error_code”:-7710,“error_description”:“Resource does not exits. file_name=testfile.zip”}}

http-functions.js is shown below:

import wixUsers from ‘wix-users-backend’;
import { badRequest, forbidden, get, notFound, ok, response, use, serverError } from ‘wix-http-functions’;
import { mediaManager } from ‘wix-media-backend’;
import wixData from ‘wix-data’;
export function get_queryMedia() {
return wixData.query(“Media/FileshareFiles”)
.find()
.then((fileList) => {
let successReturnValueObject = {
headers: {
“Content-Type”: “application/json”
},
body: {
“fileList”: fileList,
}
};
return ok(successReturnValueObject);
})
. catch ((error) => {
let failedReturnValueObject = {
headers: {
“Content-Type”: “application/json”
},
body: {
“error”: String(error),
}
};
return badRequest(failedReturnValueObject);
});
}
export function get_fileInfo(request) {
let fileName = String(request.query.fileName);
return mediaManager.getFileInfo(fileName)
.then((fileInfo) => {
let successReturnValueObject = {
headers: {
“Content-Type”: “application/json”
},
body: {
“fileUrl”: fileInfo,
}
};
console.log(“junk12”);
return ok(successReturnValueObject);
})
. catch ((error) => {
let failedReturnValueObject = {
headers: {
“Content-Type”: “application/json”
},
body: {
“error”: String(error),
}
};
return badRequest(failedReturnValueObject);
});
}

Yes that is because when you upload to Wix it is given a new name by the Wix Servers, so when you look for something online, then it must be by the Wix name and not your original file name.

You can see more about here and vote for the request too.
https://support.wix.com/en/article/request-customizing-document-file-names

So, if you go back to the Wix API Reference, you should now clearly see the correct procedure.
https://www.wix.com/corvid/reference/wix-media-backend.mediaManager.html#getFileInfo

Get a file’s information

import { mediaManager } from 'wix-media-backend';

export async function getFileInfo(file) {
  return mediaManager.getFileInfo(file);
}

/* Returns a promise that resolves to:
 * {
 *   "fileName": "f6c0f9_tg439f4475a749e181dd14407fdbd37e~mv2.jpg",
 *   "fileUrl": "wix:image://v1/f6c0f9_tg439f4475a749e181dd14407fdbd37e~mv2.jpg/original-name.jpg#originWidth=300&originHeight=300",
 *   "hash": "Ew00kXbu4Zt33rzjcWa6Ng==",
 *   "sizeInBytes": 51085,
 *   "mimeType": "image/jpeg",
 *   "mediaType": "image",
 *   "isPrivate": false,
 *   "iconUrl": "wix:image://v1/f6c0f9_tg439f4475a749e181dd14407fdbd37e~mv2.jpg/original-name.jpg#originWidth=300&originHeight=300",
 *   "parentFolderId": "2bf470f5be194b319cdb2accc3278ff9",
 *   "originalFileName": "original-name.jpg",
 *   "sourceUrl": "https://somedomain.com/img/original-name.jpg",
 *   "width": 300,
 *   "height": 300,
 *   "labels": [
 *     "Blue",
 *     "Butterfly",
 *     "Turquoise"
 *   ],
 *   "opStatus": "READY"
 * }
 */

Thanks for the information

Where can I find the Wix name? The FileshareFiles (Media/FileshareFiles) database just gives an ID which is not the name.

If I click on the “Welcome to File Share.pdf” it opens in as a pdf view in my browser and I can see the Wix name 86af49_81bf0616b57b43bc89593f924e6375fa.pdf

My testfile.zip file just downloads with the “testfile.zip” text name, I cannot see the Wix name ever (downloading Welcome to File Share.pdf just uses its text name as well)

If you use getFileInfo then you should be able to get the full info back like in the Wix Example.

Otherwise, you won’t be able to get it from the Wix File Share app as you can only download zip files and not open them like you can with pdf files for example.

Or you will have to upload the zip file to your Media Manager and get the URL from the file yourself.

Your queryMedia results will only give you in return the same as what you can find yourself if you look at the File Share collection. Unfortunately, it only gives you the path and not the actual file url which you are after.

{"fileList":{"items":[{"_id":"b1bf050b-24f5-4864-95dc-fb9dd8e6be9e","name":"testfile.zip","_owner":"07147f53-3dfa-43ca-b956-14de47bffd72","_createdDate":{"$date":"2020-01-03T16:09:41.608Z"},"parentFolder":null,"path":[{"id":"42e7107e-ee28-43fd-b4ed-9e0cae1ac964","name":"/"}],"favoriteCount":0,"favorite":false,"viewCount":1,"viewed":false,"extension":"zip","size":169250},{"_id":"4a329c75-362d-458b-9f5b-db7a88b0b2ff","name":"File Share FAQ.pdf","_owner":"86af490e-5c4e-4b24-a852-901e472f5fd0","_createdDate":{"$date":"2019-03-04T17:24:18.565Z"},"parentFolder":"51282313-61ca-4bec-976b-ff8e71687c2e","path":[{"id":"42e7107e-ee28-43fd-b4ed-9e0cae1ac964","name":"/"},{"id":"51282313-61ca-4bec-976b-ff8e71687c2e","name":"FAQ"}],"favoriteCount":0,"favorite":false,"viewCount":1,"viewed":false,"extension":"pdf","size":4353273},{"_id":"4901449a-859d-4b55-aba3-31faeec93835","name":"Welcome to File Share.pdf","_owner":"86af490e-5c4e-4b24-a852-901e472f5fd0","_createdDate":{"$date":"2019-03-04T17:24:18.434Z"},"parentFolder":null,"path":[{"id":"42e7107e-ee28-43fd-b4ed-9e0cae1ac964","name":"/"}],"favoriteCount":0,"favorite":false,"viewCount":1,"viewed":false,"extension":"pdf","size":4529986}],"length":3,"totalCount":3,"query":{"invalidArguments":[],"filterTree":{},"provider":{},"collectionName":"Media/FileshareFiles","limitNumber":50,"skipNumber":0,"included":[]}}}