Forum Academy Marketplace Showcase Pricing Features

[SOLVED] How To Send Text File Stored On Bubble Via API

Hi,

I have a text file stored in Bubble, with a file path of //s3.amazonaws.com/appforest_uf/[long _numeric_string]/[filename.txt] .

I need to send this text file to a text analytics tool (via API) when a user presses a button.

The API requires the text document location (inputted as a parameter) (URI encoded).

In light of the S3 storage, what text document location should I be entering here?

Thanks!
P

You can try Dynamically inserting the files url into the API call. Just do a search for “[table][document’s field]'s File’s URL”. That should insert the url like you have above. From what I can tell the documents aren’t actually protected by any authentication, so if you sent off that URL to the external tool it should be able to pull it without a problem.

Give it a shot and let me know.

Hi, Chris, Thank you.

That’s a great idea and useful knowledge, but it did not solve my problem.

Basically, I’m sending out the text file for analysis and getting results sent back to me and I’m viewing the results in a repeating group (RG).

What I see coming back to me is simply the url://s3.amazonaws.com/appforest_uf/[long _numeric_string]/[filename.txt].

This suggests to me that what is being sent for analysis is not the contents of the text file but the url name of the text file. Not sure why that should be…

Thanks,
P

Ah, so you’re saying that you’re getting the s3.amazonaws.com url back as a response?

Correct - but the problem might be with my API call setup.

The documentation says you need:

text
Text document content
(must be uri-argument encoded)
(required parameter)

url Text document URL
(optional parameter. must be uri-argument encoded)

Note that the text parameter is "Text document content.

I had previously assumed that this meant I was to send the storage location of the text file. But perhaps not?

If not, what other approach would there be?

Thanks,
P

Hm… As far as I know “uri-argument encoding” is when the URI string doesn’t contain spaces, tabs, or certain other special characters. Below is an example.

Non-encoded:
my text document’s content

Encoded:
my+text+document%27s+content

To me it sounds like they want you to pass the entire contents of the file as an encoded string… It’s hard to say, though, since I’m not sure which API you’re using. :wink:

Hi Chris,

I’m using the Alchemy Text (keyword) API: http://www.alchemyapi.com/api/keyword/textc.html .

I’ve tried the method you suggested and am getting an assortment of issues. Parse errors, Bubble errors, and more. Used several online text-encoders to ensure issue was not with encoding provider.

I don’t think this how Alchemy wishes us to proceed? This is meant to be a high-volume API. How could one properly encode all the text blocks efficiently?

In any event - if you could take a look at this I’d really appreciate it. Also, I should clarify: there is a way to send a URL for analysis, which I’ve used with success ( http://www.alchemyapi.com/api/keyword/urls.html ) . The problem is that, while I’ve gotten it to work with 3rd party sites (works like a charm), I can’t get it to work with the content type I need to analyse in my Bubble app.

All the content I wish to parse is in repeating groups. It seems this Url API finds the text it needs to analyze by assessing the HTML tags and proceeding accordingly. It also seems that RGs displayed in Bubble don’t mark the text in the manner needed for the API to do its thing.

So: Basically, I would like to parse content displayed in my Bubble app. Don’t really mind if that’s by using the text API, the url API, or any other method.

Thoughts?

Best,
P

So, now I’ve got it working. No encoding required, simple text (normal spacing etc) works.

I think the API might be touchy - I don’t believe I changed anything of note, it’s just working now in the way I desire.

However, there is a new problem.

Having gotten the API to work, I’ve jumped ahead a couple of steps and am sending repeating group text from my page to the API. Basically if I limit what I send to ‘first item’ it works. If I send the entire thing I get “Parse error” message from Bubble.

I’ll have to experiment more, but if you’ve seen this sort of problem before, please, by all means let me know.

Thanks for your help!!

Best,
P

3 Likes

Awesome, glad it’s working for you! I can’t say I’ve run into that issue before with the repeating group, but if I think of something I’ll let you know.

What do you mean “sending repeating group text” ?

Hi Nigel,

I figured this out. I wanted to send text appearing in an RG to an API. The text volumes were initially too large but only via the URL. Sending through the text body enabled it. The thing that tripped me up was I didn’t know was how to trigger the body as a parameter through which to send dynamic data (didn’t even know you could). Some of your posts (elsewhere) helped me through this.

Thanks very much!

Best,
P

Hi scriptschool, if you’re still reading this thread, could you elaborate a little on your solution? I have a similar need and want to do roughly the following:

  • allow user to upload csv file via Bubble (goes to S3)
  • user should take some action that triggers workflow to send the file from S3 to my API (haven’t built it yet but let’s pretend it would do some similar analysis like the text service but it’ll actually do simple manipulations)
  • my API should return new data/results to my bubble app to display.
  • might need to repeat more API calls with this new data (which should be temporary).

Thanks for any pointers. I think conceptually I’m starting to see this is possible but not sure of specifics. How you sent your repeating group text body should be pretty similar to how I send the uploaded file (not just the file url s3.amazon.etc.etc.) to my service. If I can do all this, the rest of my app is essentially adding back-end logic. I’d love for Bubble to handle all else.

Hi there,

The point I was making above was that in the end I did not actually send a text file, I sent text (i.e stored in the DB as text). If there’s a way to send an actual file, I don’t know what it is.

In your case, if you can somehow get the CSV file content into your DB, then you can POST that text as the ‘body’.

If you do figure out how to send the file, post the method here! :smile:

Best regards,
P

Hmm, ok thanks for the quick reply! I’m kind of thinking there is no way to do this with my Bubble front end. That is too bad since I likely need to write my upload UI and backend processing. My questions then become:

  • is there some way I can use Bubble to manage the usual app stuff: sign-ups, user logons, CSS, some basic app database things, etc. while incorporating my own custom UI and processing in an html area?
  • this html area needs to be aware of the user logon / user session. Can I pass some kind of token from the rest of my Bubble app to this custom portion of my app?
  • or is there another way to organize my app to accomplish this goal?

Thanks for any thoughts.

Hi -

Well, just to clarify, I gave up on the idea b/c the particular API I was using didn’t want a CSV it wanted a text file, and it wouldn’t take a URL so the idea of sending the S3 URL was out.

Furthermore, I did begin looking into putting the file into Dropbox when it is uploaded (instead of/in addition to Bubble/S3), then creating some sort of automation (Zapier, etc.) to send the Dropbox file to the API. But in the end I didn’t fully explore this b/c I found a simpler method (altogether different app design and not pertinent to your question).

So, first of all: are you sure you need to send an actual file to your API? Could you send the data some other way (render it first in HTML, then send the page to the API?)?

Second, what about uploading the file and somehow getting the data into Google Sheets? There are tons of services out there that interact with Google Sheets, perhaps one of these can help you (user uploads file, data is sent to google sheets using 3rd party service or string of services)? Once it’s in there you can do almost anything with it (including running it back through your own API).

I wouldn’t give up on Bubble yet for handling all the tasks you need. Generally you can do what you need to with perseverance - the main issue is, is it worth it to you? Some tasks become a bit like a Rube Goldberg machine, which can be a bit unwieldy, but if you have one specific task to do, it can be ok to string a sequence of tasks together. Often, I find that by working through the Rube Goldberg-like approach, you understand the methodology well enough by the end to vastly simplify and have a Eureka moment that vasty simplifies the whole thing into one or two steps.

As for your last question (i.e. if you decide not to attempt the above and you decide to use Bubble for front-end and alternative services for your backend), I can’t help you here as I have not experimented – but I’ve seen discussion on the forum on these sorts of queries elsewhere. Perhaps you’ll find some of them of use (if you search through).

Good luck!

Best regards,
P

1 Like

Thanks. I think those approaches could work. Depends on how big the files would get. AFAIK there isn’t a way for the user to load the contents of the CSV to HTML, but Sheets could work. Yeah, it does seem Rube Goldbergish, but I still like it. I want to let my user do a Rube Goldberg sequence of tasks.

What was the size limit?