How to parse video public Id from url and add to AvancedVideo
Hi,
So I have this video_url for my video:
https://res.cloudinary.com/my_cloud/video/upload/s--blahblah--/vblahblah/courses/Lighting/videos/Lighting.mov
When I try this on my React compoenent:
<AdvancedVideo cldVid={cld.video(video_url)} controls/>
https://res.cloudinary.com/my_cloud/video/upload/https://res.cloudinary.com/my_cloud/video/upload/s--blahblah--/vblahblah/courses/Lighting/videos/Lighting.mov.mp4?_a=ATAJZAA0
not found.
What's with the added prefix, what's the benefit of doing this, I get this url after I POST my video file to Cloudinary and for some reason does not work out of the box with your
I've spent too many hours trying to slice this to make it work, all other react video players just take the original video_url and work, can someone please tell me where do I slice the video_url (if that's the issue)?
Here is a sample:
Thanks
-
Found this post that helped https://support.cloudinary.com/hc/en-us/community/posts/360006941639-How-to-programmatically-retrieve-public-id-from-URL-
Made this function:const extractPublicId = (url) =>{
let first = url.slice(url.indexOf('upload') + 7)
let second = first.slice(first.indexOf('/') + 1, first.lastIndexOf('.'))
return second
} -
Still no luck, got a 401 deny or ACL failure, so I added the signature to the url but now it returns a 404 again,
https://res.cloudinary.com/cloudID/video/upload/v1/s--somesecret--/v323232/courses/NAME/videos/VideoNAME.ogg?_a=ATAJZAA0
What is that 'v1' added after upload now? -
Hey Andres. Thanks for getting in touch. My name is Danny and I'm on the Customer Success team here at Cloudinary.
AdvancedVideo expects a Public ID to be passed to cldVid, rather than the full URL of the video The public ID is returned in the upload response, so it's best to store this alongside the URL in your DB for future reference.
Looking at the URL you've shared above, I see you have v1/ and v323232/ - This relates to the asset version, and it seems that the extractPublicId function has grabbed the version from the URL and saved it as part of the public ID.
To test, could you please try referencing "samples/elephants" and let me know if that works for you? The delivery type for that asset is just upload, so you shouldn't need to provide a signature or anything for it to work.
Thanks,
-Danny
Post is closed for comments.
Comments
4 comments