[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?