ionic 5 PDFTron Webviewer doesn't have access to file URLs because of browser security restrictions - ionic5

I try to integrate the PDFTron API in an ionic 5 application in which I download the pdf from the server, store them on the phone and then open them with the API
currently when I put the files in the assets folder of my ionic project, the api opens it without problem
but when I download the file to the phone memory and try to open it with the API by passing the link of this file, I have the following error (on the image)
Is there a way to fix this or store the downloaded files in the assets folder?

for those who encounter this same problem, just convert the native url (Ex file: ///storage/emulated/0/USL/20.PDF) into a url that the webviewer accepts using this:
let safeURL = win .Ionic.WebView.convertFileSrc (your native url);
you can also follow this link: where was file location downloaded in Ionic

For security reasons, browsers normally don't allow JavaScript pages to load local files from the local environment. Your option for this is to either use local paths if possible to run or to create a local server that access and serve the file to the client side.

Related

Remove files from Public folder from client with Next.js using routes api

I have an application where the user generates QR codes. These generated qr codes are stored as png in the public folder so that he can access them and download them.
The user can delete the QR codes as he wishes and I dont want the QR codes to stay in the public folder if it wont use them.
Is there anyway to access the public folder from the routes API and have some function delete a specific QR code's png?
Thanks!
Resources in the public folder are statically generated and shouldn't be modified during runtime. In development, it works because the dev server is doing some magic for you, but it's not a scalable solution. Assuming you could get this to work, you will run into issues when you want to scale out your service.
Consider that you run multiple instances of your Next.js web application. Which public folder would the file go into? What if you have your application versioned through source control and you deploy it to a remote service like Vercel or AWS using CI/CD. What will happen to the images in the public folder when the new version is pushed?
Instead of trying to upload resources to the public folder during runtime, I recommend using a SaaS solution to host the QR codes. Good options are AWS S3 or Cloudinary. You can upload the image temporarily to the API route and then use an API to upload the image to the service you choose.
Alternatively, you can use something like AWS s3 presigned URLs to make uploading images even easier. Simply have your API route return a presigned URL to the client and have the client upload directly to Amazon's servers without having your application serve as a middleman.

How can I deploy my web app on something like GitHub Pages or Netifly if I don't upload files with sensitive data in them?

For example, I have a config file where I store keys such as client id and client secret. I've put this config file in my .gitignore so that it won't be pushed with the rest of my project, but how would the versions on GitHub and Netifly run the project correctly if it isn't able to access that config file?
Is there some way to keep the config file private (without making the entire GitHub repo private) while still including it in the files on a hosting site?
Thanks!
On this case, you have some ways to do that:
Use Environment variables doc
Use an external API where you can fetch your secret data.

Is it possible to build react+redux project to static and place in CDN

I am new in react+redux. Recently I got a task and have no idea.
Is it possible not to use any web server to run my react+redux project?
After building my project, I got a folder of static files.
Is it possible to place those in CDN not having web server eg. nodejs or tomcat?
thanks.
If you do not need save data on server - you do not need it. Take a look on GitHub pages for sample.
Of course you can but you need an HTML page to be parsed by the browser, in which you would include the necessary SCRIPT tags to load and run your React app.
I recommend you give Surge (https://surge.sh/) a try, it's free right now and you can easily host your React project with ease (including the .html files and every asset generated by your build). You can even create a npm script that builds and then deploys from the CLI with a single surge call. Works like a charm!
You can even use a custom domain name, or choose a specific surge subdomain if it's available, like gibbok.surge.sh. ;)
No it is not possible without a webserver.
If your app is a static website for example, with no server functionalities (like nodeJs) you could host your builded application (static files) on any simple http server included github pages without setup a nodeJs server.
If you app has some dynamic functionalities, example it use nodeJs to work with server file system or db, you need a node server.
In both cases a http server is necessary to delivery JS/HTML and assets to the browser when requested.
On a CDN you could store some static files, which can be used in your project, which is great if you are building a js library.
In case you do not want to care about the http server you could use any simple hosting solution, example GitHub page, or any hosting which allow running a website with some static files.

How do I refresh resources folder of web application?

I'm developing a web application in which I want to insert users and be able to display files that they upload via a search option. I can get all of the logic that I need sorted and the files uploaded into the correct directory. However, if I insert a new user into the db, the web app cannot find their file in the directory until I restart the server.
How can I make it so that the resources directory of my web app automatically gets refreshed by the server? I'm developing in Java/JSP and using Tomcat as my server.
Thanks!!
I'm guessing you're putting the files into the src/main/resources folder, then it's being packaged into the artifact and then you access them as the classpath resources. Then the next portion of the resources is going to be available after the next packaging.
Instead you should access the Files via usual File System and Absolute or Relative paths.

how to upload files in cpanel file manager via xmlapi

I developing an application which has static content builder for HTML pages. I am able to create ftp account and addondomain in cpanel via xmlapi but I dont know how to upload it in cpanel file manager. I want to know api1 or api2 syntax for file uploading in cpanel. Please help me. I am waiting for your response. I am using PHP for backend programing.
There should be an Upload button on the main toolbar (see here - http://blogerr.net/getting-started-with-file-manager-in-cpanel/ ). If you can't see it, you may need to reset your cPanel configuration...

Resources