How to work with .ashx data file?

Hi all,

Hoping someone has had the same issue and can help me out. I can’t find much on it on the forum but I doubt that I am the only person with this issue.

I am using the Bubble API connector to convert part of a webpage to a PDF file using the Grabz.it RESTful API: Try GrabzIt's Free REST Screenshot and HTML Conversion API

I set up an API connection using the Bubble API connector and all is working as you would expect, except for 1 thing.

When I initialize the call it all works well. The call goes through and you get a PDF file back without any errors. So far so good.

The problem is that now when I use that API in a workflow somewhere Bubble sets an extension to the file that is .ashx. So when I store that file in my Bubble database and open it as a URL the file opens as a .ashx file instead of a PDF file.

I can’t figure out why it would work with the initialize file correctly and it doesn’t work with the use of the API afterward.

I see 2 possible solutions:

  1. Find out what is different in the Bubble backend that makes the Initialise call work but not subsequent calls.
  2. Find out how to open a file that gets stored as an .ashx file as a PDF file in Bubble.

I know that it is easy to convert them afterwards but I want my App users to be able to simply download a PDF file and don’t want them to have to struggle to figure that out.

Below is my API set up:

Some help would be much appreciated.

I’m not sure that the issue is the settings. Are you sure that when you call the endpoint in your action all value are correctly set and this return back a PDF file?. What I think it’s that (maybe) the url is not provided correctly, the API cannot process the call correctly and you get a “file” that is the error page or message probably. If you are using your action into a page and you can use step by step, you can inspect what you provide to the API. And you can test the same thing in Postman or Insmonia. Also, inspect logs to see if there’s no error.

Can you also share your Action settings (call and after what you are doing with the file)

Hi @Jici thanks for the input.

Unfortunately, that doesn’t seem to be the issue. The file that comes back is the proper PDF, no error. I can open it and it is the actual PDF file. The issue seems to be that with the API initialize call the ending of the file name is overridden somehow by Bubble to equal: api_initialize_file.

When running the API in the workflow the file name is always equal to convert.ashx. This then means it also stores and opens it as an .ashx file.

The action settings below (as well as screenshot of the file in the database).
I am using the exact same action steps for some other PDF creation APIs that I am testing and they all work well as they don’t have that .ashx ending.

Screenshot 2021-03-02 at 13.10.55

That service is apparently using the ASP.NET web framework, and as explained here:

…so it’s not Bubble that’s setting the file extension. Bubble is just giving it the name provided.

The solution would normally be to simply rename the file after “downloading”, but unfortunately, I don’t think there’s a way to rename a file in Bubble storage. :slightly_frowning_face:

Maybe contact Grabz.it support to see if they can offer a work-around.

-Steve

Yes. I didn’t know that the file was a PDF and not just a wrong file :stuck_out_tongue: that change everything.
In the Doc, there’s a title field you can add. I suggest you to add this and see if this change something.
I don’t think actually there’s an easy way in Bubble to rename file like @sudsy said. But there’s a lot of tools that can do the same thing and work great like “cloudconvert” that you could consider.

@Jici and @sudsy thanks so much for the help and answers.

As it turns out the issue only happens with Chrome and not on Safari.
Still strange to me that during the Initialize call the issue (even in Chrome) doesn’t exist since somewhere the file name gets set to equal api_inilialize_file whereas for any subsequent calls it gets set to equal conver.ashx.

So somewhere Bubble does override this during the initial call but my guess is that that place isn’t exposed to users.

I’ll look into cloudconvert as well to see if that could help solve it.

Thanks again

1 Like

@Bubble could you clarify whether the assumption is indeed correct that Bubble overrides something during the Initial call to change the file name to api_initialize_file that can’t be replicated in subsequent calls?

Where is that name set, that is really the question I guess.