Seemingly errorless JavaScript not executing

I’m working on an app that involves sending a user-uploaded video file to another server where a Python script does the work. The video is then sent back to Bubble for the user to download.

I got the concept working with Bubble API Connector but then realized the file size cap was way too low for my needs.

I’m now trying to send the user-uploaded videos to my server using workflow action JS provided by Toolbox.

The following code is supposed to execute after a user presses a ‘go’ button.

The error I get is:

Bug in custom code SyntaxError: Unexpected end of input
at eval (PLUGIN_1488796042609x768734193128308700/Toolbox-action–Run-javascript-.js:3:51)

I’ve tried slightly different iterations of this same code over the last couple of hours and haven’t had any luck. I feel like I’m missing something super obvious so any help is greatly appreciated.


If your FileUploader is the one that’s built-in into Bubble, then FileUploader UploadHere's value is a string representing URL to the already uploaded file, it is not a javascript File itself.
And, though it’s now meaningless, to get rid of the syntax error you need to surround that value by quotes: sendFileToAPI("FileUploader UploadHere's value");. Note that in sendFileToAPI function will always be undefined as file is a String. You have to adjust your python script at the endpoint to accept URL and download it to process further.

1 Like

Thanks for the help, really like this approach.

I’ve made the necessary changes and unfortunately my API is receiving a 403 Forbidden when it tries to download the video file. The file has no privacy rules and I can view it just fine from my browser. Any insight?

Seems almost identical to this: File Uploader's URL 403 Forbidden

Can you show a single record in the File Manager of the file you’re playing with? Something like this:

Particularly, I’m interested if there’s something displayed in Attach To column against the file?

Shot in the dark but could the fact that they’re all uploaded to the dev database have anything to do with it?

Ok, thanks. You need to adjust the code a bit:
sendFileToAPI("FileUploader UploadHere's value");
sendFileToAPI(new URL("FileUploader UploadHere's value", "Website Home URL"));
Note that FileUploader UploadHere's value and Website Home URL are both dynamic values, not a plain text.

Still no dice. Was actually already testing a full https url in a test script so unfortunately this wasn’t the issue.

Don’t think there’s anything programatically wrong with what I’m doing on bubble’s end anymore; my API is receiving the URL in perfect format. It’s just having trouble downloading the file.

Here is the test script I’m using to isolate the 403 error:

I’ve also tried adding a variety of different headers to the request - no luck.

Your file is protected for some reason:

You can open it in browser because you are logged in into the editor or app. Try the same using anonymizing mode (right click → open Incognito / InPrivate): tikmate.app_7174937348231269637_hd.mp4.

Sorry for the confusion. I deleted that file after uploading the screenshot.

I tried accessing it in Incognito prior to deleting and was able to do so without any issues.

Ok, then I can’t go much further.
It works just fine with a similar node.js setup.

What I could suggest is to add “Cache-Control: no-cache” header to the request, so you would need a bit more code:

opener = urllib.request.build_opener()
opener.addheaders = [('Cache-Control', 'no-cache'), ('Pragma', 'no-cache')]
urllib.request.urlretrieve(url, save_path)

This topic was automatically closed after 70 days. New replies are no longer allowed.