Page 1 of 3

Problem Loading a Pdf File

Posted: Wed Mar 04, 2015 1:02 am
by leonardo

I have some pdf files in the database. In my app I have a label on the list item to capture the pdf name I want to load. The click event code is:

codevar thepdf=$(this).find("[name=pdfname]").text(); // + '.pdf';
var pdf = 'https://api.appery.io/rest/1/db/files/54bd8eb7e4b03b3a80116534' + thepdf;
window.open(pdf, '_system');
/code

But I get the following error:
code{"code":"BCXX004","description":"No resource method found for GET, return 405 with Allow header"}/code

I want to load the pdf into another page in the app.
What component do I need to use to and how should I code it to accomplish this?


Problem Loading a Pdf File

Posted: Wed Mar 04, 2015 9:47 am
by Illya Stepanov

Hi -

Your URL should have master-key, in other case https will not allow you to view this file.
See the details here: http://gyazo.com/0d7aaf0b28f9d6c31b1e...


Problem Loading a Pdf File

Posted: Wed Mar 04, 2015 8:52 pm
by leonardo

Hi Illya:
I implemented that like this:
code
var thepdf=$(this).find("[name=pdfname]").text(); // thepdf here is: h2013-2.pdf

var pdf= 'https://api.appery.io/rest/1/db/files/54bd8eb7e4b03b3a80116534/' + thepdf;
masterKey='abe75e48-f875-47be-946a-502e7d7566b2';
window.open(pdf, '_system');
/code

I still got an error:
code{"code":"DBFG155","description":"File with name h2013-2.pdf not found in database 54bd8eb7e4b03b3a80116534"}/code

But that file name is in the database collection. What should I do here? How can I render the pdf in a component container in the app?


Problem Loading a Pdf File

Posted: Thu Mar 05, 2015 6:18 am
by Egor Kotov6832188

Hi Leonardo.

You are using OriginalFileName property saved in pdfname label instead of FileName.
Map FileName to the label and use it as part of url


Problem Loading a Pdf File

Posted: Thu Mar 05, 2015 8:38 pm
by leonardo

Still haven’t gotten it to work. The filename in the database shows up as “-id” under mapping. I mapped the id to the pdfname but still got the error:
code{"code":"DBFG155","description":"File with name 54efc01ae4b0b8b4c84f4345 not found in database 54bd8eb7e4b03b3a80116534"}
/code

I observed that “54efc01ae4b0b8b4c84f4345” is the id given to a filename in the list service:
code
[
{
"id":"54efc01ae4b0b8b4c84f4345",
"createdAt":"2015-02-27 00:53:46.345",
"updatedAt":"2015-03-03 22:57:17.196",
"th":"h2015-1.gif",
"pdf":"h2015-1.pdf"
}
]
/code
But the real filename (id) in the database is ="7b0adbeb-1aa4-4045-b61d-b02fedc46c8d.h2015-1.pdf" and if I hardcoded that name, the pdf opens.
Can you give an example of how to resolve this?


Problem Loading a Pdf File

Posted: Fri Mar 06, 2015 10:38 pm
by leonardo

Please help, I'm stuck.


Problem Loading a Pdf File

Posted: Sat Mar 07, 2015 12:00 am
by Illya Stepanov

Hi Leonardo -

Unfortunately it's not very obvious for us the way you store and work with links in your app.

Please explain this with more details or share your app and your DB with us and explain the steps to reproduce your problem inside the app.

It's better to work with files straightforward as explained in our documentation or slightly modify this approach with JavaScript - -- http://devcenter.appery.io/documentat...


Problem Loading a Pdf File

Posted: Sat Mar 07, 2015 11:46 pm
by leonardo

I see what the problem is. I have a database with pdf stored in it. I also have 3 collections in the database. One of the collections is called "maglist," I have generated a database list service for it and mapped for the UI components. This maglist has a filename/id.

I have identified that the filename given to the maglist is different from the filename in the database. I couldn't find a way to map the filename in the database to the UI component.

I've shared the app with support. Thanks.


Problem Loading a Pdf File

Posted: Sun Mar 08, 2015 12:01 am
by Illya Stepanov

Please specify apps name and also database would help us understand the issue better.


Problem Loading a Pdf File

Posted: Sun Mar 08, 2015 1:59 am
by leonardo

The app name is "mag" and it has only one database, named "magpdf." Thanks.