Upload pdf public url

Question:
I have been working with Wix Dev and I am having trouble obtaining the public URL of a file uploaded through a PDF or image. When I attempt to capture the URL, I receive an invalid path, such as:

wix:image://v1/687072_51ad821aa5294451a509f18bf569bd2c~mv2.jpg/Credifirma2.jpg#originWidth=1200&originHeight=409

Is it possible to obtain the public URL in any way? Thank you very much for your assistance.

Product:
Wix DEVO

What have you already tried:

Here is the code I am using on the frontend:

$w.onReady(function () {
    // Add event when a file is uploaded
    $w("#uploadButton1").onChange((event) => {
        // Get the uploaded file
        let file = $w("#uploadButton1").value[0];
        // Upload the file to the Wix media library
        $w("#uploadButton1").startUpload()
            .then((uploadedFile) => {
                // Get the URL of the uploaded file
                let fileUrl = uploadedFile.url; // Public URL of the file
                
                // Display the URL in the text element
                $w("#text14").text = fileUrl;
            })
            .catch((uploadError) => {
                console.error(`Error uploading file: ${uploadError}`);
                $w("#text14").text = "Error uploading file.";
            });
    });
});

Go to your Wix media manager and click on the 3 dots to copy URL from a real file. Do the same for an image.

Now that you have the pattern of the URL, go back to your original code and parse the variables. Now you can build out the real URL now that you have the pattern and the values.

1 Like