File Repo URL when using Business Logic

Hi,
I’ve setup my File Repo Access URL and uploaded a number of files to the backendless storage, I’ve referenced these files in a couple of my backendless tables. When getting a url directly for these objects in storage they work fine and use my custom domain to load them, when getting the file urls from the backendless tables via the standard backendless api these also seem to reference my custom url as the file location which is great.
However
The issue I have is, I’m using a java Business Logic service for all of my api requests, when a user calls a business logic function that returns the objects in the various tables, the custom URL isn’t present on the files, instead it reverts to the standard url which has my api keys in it.

Is it possible for the URL to be my custom domain when using business logic?

Thanks.

Hello @Reece_Smith

When you request Data object inside the BL using the JavaSDK it uses a CloudCode API Key and in this case the server returns file references which have the CloudCode API Key.
However, there is a fileReferencePrefix option to ask the server return all the file references with the prefix you want.

Here is an example on how to use the option:

DataQueryBuilder queryBuilder = DataQueryBuilder.create();
queryBuilder.setFileReferencePrefix( "http://your-custom-domain.com/" )

Backendless.Data.of( "Person" ).find( queryBuilder );

Hi @vladimir-upirov
Thanks for coming back, that doesn’t seem to work, my file objects are in children tables, my code loads:

Backendless User → checkIn (Table) → Bar (Table) → Photos (Table) → Files are here:

Response from server:

Thank you for sharing this, I just created an internal ticket to investigate the issue BKNDLSS-26218.
Could you please provide your AppId?

Thanks Vladimir, it’s AFF18CB4-DF5E-430B-8BEE-1AF97113767C

thanks, our Java engineer will check this case and answer as soon as possible

Hi,

Any update on this?

Thanks,
Reece

Hello @Reece_Smith

The issue has been fixed and currently, this is on the testing stage, we are going to release it once the QA department verifies it. We are planning the next release the next week.

Thanks for your patience!

Regards, Vlad

Hey Vlad,

How did the testing go? Did this get deployed?

Thanks
Reece

Hello @Reece_Smith

The issue was tested and waiting for release. It should be done in the next two days.
Thank you for waiting. We will inform you after release.

Regards, Dima

Hello @Reece_Smith

We’ve published a new version of SDK ‘6.3.2’ https://mvnrepository.com/artifact/com.backendless/backendless/6.3.2 that should fix this issue. Could you please try to install it and verify if it’s working for you?

Regards,
Inna

Hi Inna,

It looks like it’s almost there, I’ve added:
queryBuilder.setFileReferencePrefix( “http://dev.tipple.io/” );

When the API service returns back the file reference from that query I get:

http://dev.tipple.io/BarPhotos/859B04B1-C3F3-4A86-82BE-3C2E062A332F.jpg

it should be:

http://dev.tipple.io/api/files/BarPhotos/859B04B1-C3F3-4A86-82BE-3C2E062A332F.jpg

Note the ‘api’ and ‘files’ part of the URL is missing? Should I change my setFileReferencePrefix to http://dev.tipple.io/api/files/ ? Or should it do it automatically?

Note it does work if I add /api/files/ - just want to know is that the expected way to do it?

Hello @Reece_Smith

I need some time to check the case, I will let you know about the result of the investigation

Hello @Reece_Smith

just want to know is that the expected way to do it?

yes it is expected

The following url http://dev.tipple.io/BarPhotos/859B04B1-C3F3-4A86-82BE-3C2E062A332F.jpg try to find the file by the following path web/BarPhotos/859B04B1-C3F3-4A86-82BE-3C2E062A332F.jpg and you do not have access to web folder and do not have the BarPhotos inside web.

So if you call http://dev.tipple.io/ without api backendless will look up in web folder.

Also, you should give access for NotAuthenticatedUser role. I know that it works as is, but generally should not because NotAuthenticatedUser role and TippleUserRole has the same priority, but permission for NotAuthenticatedUser is DENY. And if some role on the same layer has deny access then we deny the operation. I have created internal ticket BKNDLSS-26485 to fix the issue. If you do not change permission for NotAuthenticatedUser role it will deny access to the files when we release the fix

Hi @sergey.kuk

Good spot, however I do not want NotAuthenticatedUser to have access, so I have enabled it on AuthenticatedUser which I believe will solve the problem you mentioned above?

Thanks,
Reece

Hello @Reece_Smith

sure, it will. If a user is authenticated then he will have AuthenticatedUser role

Thanks @sergey.kuk @Inna_Shkolnaya @Dima @vladimir-upirov for your help getting this fixed! Have a great weekend