kay
Posts: 0
Joined: Fri Oct 31, 2014 2:24 pm

Evgeny Karachevtsev Example - Display a list of pdf files via listitem component

https://blog.appery.io/2015/12/learn-...

I have successfully completed the above example by Evgeny Karachevtsev and used the listitem component instead of the link component. I am trying to show a list of the files belonging to the signed in user instead of the test file. I have removed the testfile from the window.open javascript and tried replacing it with various options such as, filename and file_name to correspond with the fields within the Files collection unsuccessfully. Has anyone got a solution for this?

Thanks in advance

Serhii Kulibaba
Posts: 150
Joined: Tue Aug 27, 2013 1:47 pm

Evgeny Karachevtsev Example - Display a list of pdf files via listitem component

Hello Kay,

Could you clarify what you have tried and what exactly does not work?

kay
Posts: 0
Joined: Fri Oct 31, 2014 2:24 pm

Evgeny Karachevtsev Example - Display a list of pdf files via listitem component

Hi Sergiy,

I've completed the above example to display the linked file and it worked fine until: It directs you to add the JavaScript code to the image component URL property.

(1) The image component doesn't have a URL property. Is this a typo and supposed to be the Link Component URL, because I have utilised that instead?

When I invoke the Link, it opens the window as expected and shows the testfile but I also get an error on the main screen of Bad Request.

The window.open() function, still states to utilise the testfile within the coding line: xxxxxx-d117-4daf-acaa-63a5951710f3.test.pdf?

In my 1st post above I describe removing this testfile from this window function and replaced it with fileName, to get a link to the Files Name column in the Files Collection. But get an error message of: "code":"DBFG155","description":"File with name fileName not found in database.

(2) I have utilise the _user_read_service to invoke a list to be displayed, but not sure of the mapping process after that?

Part of the example pasted below:

[quote:]
If you have a list of PDF files that you would like to display in your app, that’s also easy to do.

Generate a service that returns a list of all the files (Create new Database Services). When you complete the Success (output) mapping, add the following JavaScript code to the image component URL property:

var DB_ID = '54b88d61XXXXXXXXX6676d3f5e';
var masterKey = '54545454';
return ' https://api.appery.io/rest/1/db/files/' + DB_ID + '/' + value + '?masterKey='+masterKey;

Where DB_ID and masterKey are your actual database ID and master key of your database.

Open Events panel and chose Run Javascript event for your link component. Add the following code:

window.open('https://api.appery.io/rest/1/db/files...', '_system');

Save and test your app in a browser. When you click on the link the new page is opened and your PDF file is displayed on this separate page.

The same way it works on the device. Export your app and see that when you click on the link your system browser starts to work and displays your PDF file from Appery.io database.

With that, you’re done: you’ve successfully displayed a PDF file that was uploaded to a database in your app.

[/quote]

Return to “Issues”