@robmich No worries man. I wasn’t able to get it working in the way I was originally attempting, but I found a kind of jerry-rigged workaround to get what I was after.
My site has a feature where guests upload videos, and those are the videos that I need to access in a downloadable Url. So, I decided to try to capture that info individually when they upload, instead of trying to get them all at once later on. At first, I tried using the getDownloadUrl function in a beforeInsert hook, but it still wouldn’t work for me. The only media-backend function that I could get working in that was the playbackUrl one, but of course that url doesn’t work for my purposes (I need a url that a third party api can read/download).
SO my jerry-rigged solution was to create a button on the page immediately following the upload page, where they “Review & Edit” what they uploaded before submitting it. The button is then linked in the editor to the videoField of the currentItem, the way you would if you wanted the guest to be able to download it. Then, in the code, I assigned the .link value of that button to a new “downloadUrl” collection field via .setFieldValue. Lastly, I set the button to “hidden”.
Now, every time someone uploads a video, the item in the collection will also have a url that I can use, which weirdly is not one that I can access from any of their api code it seems (these urls end with “/file” which the api ones didn’t from what I could tell
). So it’s a little bit of a silly approach, but it works for me haha
*By the way, just to answer your questions, I was calling it from the backend, using a web module, and this weekend I did try console logging from every possible point in the code I could think of, just to get the best picture of what is happening and where the problem begins. But I couldn’t find anything. It seemed to do everything totally fine, until it gets to that function. Then, depending on how I attempted it, it would either be a blank array, or an array of 34 blank objects for some reason. It did that in my beforeInsert hook attempt as well. Instead of a url, it would only return “{}” to the collection.
So I honestly have no clue what’s going on there, and I’m glad it’s not just me who is struggling to figure it out haha aside from the documentation, there’s very little examples out there of the media-backend api, so it’s difficult to research possible errors, but I’ll keep my eyes peeled for any more insight on this in the future.For now my jerry-rigged method will do the job though so I’ll go with that! haha Thank you very much for your help with this. I really appreciate it!