When you need to load into a WKWebView a local HTML file that references a local javascript you can use this syntax.
webView.loadFileURL(htmlURL, allowingReadAccessToURL: jsURL)
However when the html file references multiple js files included into a local folder, which is the correct syntax?
I tried passing the NSURL to the local folder but it is not working.
Thanks.
in that case u need to make a folder contains all the files access from html file, then add it to project, while adding to project select create folder reference and then get the path for the html file and load it
var path = NSBundle.mainBundle().pathForResource("myindex", ofType: "html", inDirectory: "myfoldername")
var pathUrl = NSURL(string: path!)
then load pathUrl to web view
Related
I am trying to load an image from my XCode assets library:
Using this code:
[self.imgIcon setImage[UIImage imageNamed:#"symptoms/anxious.buz"]];
It works if I don't have the asset in a folder in the assets library. I've also tried renaming it to .png, as well as using 'symptoms.anxious.buz'. Because it works without a folder, I suspect there is some special way to form the path to indicate you want to look inside a folder.
What is the proper grammar for loading an asset from inside a folder of the assets library?
If you want the name of the folder to be part of the image name then you need to tick the Provides Namespace option on the folder in the asset catalog...
Otherwise you can just use the asset name without the folder. So in your case...
[UIImage imageNamed:#"anxious.buz"]
I have a frontend in NuxtJs. I want to list out all the PDFS stored under the static folder and make a dynamic link to open those documents in the browser as a separate window.
So I want to get the list of all the files of specific folder.
Nuxt.config.js uses fs module as default loader.
we can add this snippet of code to the Nuxt.config.js file and store the response to the env variable so that it can be used anywhere.
const fs = require('fs')
// To read Static Files
const files = fs.readdirSync('./static/pdfs')
process.env.STATIC_REFERRAL_DOCS = files
My folder structure of Angular 10 project is given below
-Backend
-e2e
-node_modules
-src
I want to access backend/uploads/profilepic.jpg in the angular's index.html page. Simply, i just want to load an image file in the front end which is uploaded in the backend folders.
A static resource, like an image, is either bundled inside the angular webapp, by adding it to the assets folder (e.g. 'src\assets\images') and have that folder referenced inside angular.json:
"assets": [
"src/assets"
],
Or, make the backend serve that image and simply access it from the frontend like this:
<img alt="xyz" src="https://yourdomain/img_test.png">
If both the backend and frontend are hosted on the same domain, you can use relative path for the URL, i.e https://yourdomain can be omitted.
Finally, I found the solution. In order to access the files of the 'uploads' folder which is located in the backend folder. I have to make that folder static. for that in my server.js file, I have added below code
app.use('*/uploads',express.static('uploads'));
after that, I could load my image file from that uploads folder by calling
http://localhost:8090/uploads/image.jpg
I can't load local files (jpg, png, json...) with either
import img from '../../../../assets/images/myImage.png';
require('../../../../assets/images/myImage.png');
With import VS Code notifies me that the module is not found. I can't see files in folders. What am I doing wrong?
At first you would check if file path is correct.
If file path is correct you load it simply.
(../../../../ is bad statement for files loading.)
The step is below
Please define package.json file into assets folder.
The content of package.json file looks like this
{
"name" : "#assets"
}
then you can load the file which is in assets folder like this
const img = require('#assets/images/myImage.png');
I am using liferay 6.0.5. I am uploading file using following code.
UploadPortletRequest uploadRequest = PortalUtil.getUploadPortletRequest(actionRequest);
String submissionFileName = uploadRequest.getFileName("file");//uploaded filename
File submissionFile = uploadRequest.getFile("file");
this works fine and upload file in tomcat's temp directory with some different name. What I want is.."There is one folder docs in my project directory. I want uploaded file in this directory". How to do this in liferay..?
If you want to change the temp directory for the file upload then you can change the following property in portal-ext.properties:
com.liferay.portal.upload.UploadServletRequestImpl.temp.dir=C:/MyTempDir
Hope this is what you are looking for.
If you want to add files to Liferay's Document Library then check out the following classes:
http://docs.liferay.com/portal/6.0/javadocs/com/liferay/portlet/documentlibrary/service/DLFileEntryLocalServiceUtil.html
http://docs.liferay.com/portal/6.0/javadocs/com/liferay/portlet/documentlibrary/service/DLFolderLocalServiceUtil.html