Needs to include this file (http://trailers.apple.com/appletv/us/js/application.js) in a Meteor.js project.
The file can't be in the public folder, and it has to be under PROJECT_ROOT/appletv/us/js/ folder.
But whenever I include the file, it crashes Meteor.
Any advice on how to ignore this arbitrary file in an arbitrary folder?
Just add
atv = {};
To the first line of this application.js
Other solution
Move your application.js to /lib, then create /lib/lib/hack.js
So your project will be:
<project>/lib/lib/hack.js
<project>/lib/application.js
<project>/*stuff*
And put
atv = {};
As the content of hack.js
Why can't it be in /public? /public is copied to the root of the server when deployed. So /public/appletv/us/js/application.js will be app.com/appletv/us/js/application.js when running.
Related
I want add an image to hugo's md file. And I want see it on local and website, and use a single directory to store it. So I try to put it on /content/posts/image/xxx.img and write md file with ![](/content/posts/images/2022-11-10-17-33-49.png) it's work in vscode but not in website. Is there way to get it?
Find it in hugo https://discourse.gohugo.io/t/how-to-add-image-to-hugo-with-local-and-remote/41391/8
The answer is change the conf file.
[[module.mounts]]
source = 'static'
target = 'static'
[[module.mounts]]
source = 'images'
target = 'static/images'
I'm fairly new to Dart and Flutter, and I'm having trouble to overwrite an existing assets image from a source image.
My attempt:
try {
File localFile = File('assets/images/myImage.png');
localFile.writeAsBytesSync(originFile.readAsBytesSync());
catch (e) {
log(e.toString());
}
I get:
[log] FileSystemException: Cannot open file, path = 'assets/images/myImage.png' (OS Error: No such file or directory, errno = 2)
I did define the assets folder in pubspec.yaml:
assets:
- assets/images/
Ok, so I've read somewhere that the asset file can be accessed like this:
import 'package:flutter/services.dart' show rootBundle;
final byteData = await rootBundle.load('assets/images/myImage.png');
But I don't know how to convert byteData to a File object that represents the actual file.
I think I'm missing something very basic here. Or maybe is there is a proper way to do this that has nothing to do with this approach?
Please help.
Thanks in advance!
If you want to write a file on a user device you should look here: https://flutter.dev/docs/cookbook/persistence/reading-writing-files
Shared preferences are a space in a phone where you app can write, so it's exactly what you want!
Assets are part of you app and are not meant to be modified within the app.
During a build, Flutter places assets into a special archive called
the asset bundle that apps read from at runtime. According to the flutter website
Hope this helps!
I want to save all files paths inside of a media library folder in kentico.
I found this code for one file but I don't know which Class to use to get all content any advice, please.
MediaFileInfo updateFile = MediaFileInfoProvider.GetMediaFileInfo(library.LibraryID, "NewFolder/Image.png");
This should get all the files in a specific media library.
var files = MediaFileInfoProvider.GetMediaFiles().Where("FileLibraryID",QueryOperator.Equals, library.LibraryID);
I'm creating a project of a school. I want to show the uploaded stuff by teachers to students.
But I also need to save the file in the folder which is named as faculty name. Student will be able to browse the main directory and after that he can go in the particular faculties folder.
How can I do it? Any suggestions will be appreciated.
For file upload I would start with example like in this answer. Moving files from temporary folder could be easily done by the file uploading action.
For browsing files in your case I would create an action that is able to navigate to the folder where the files are and get a list of files from that folder. Something like this
String file = application.getRealPath("/upload");
File f = new File(file);
String [] fileNames = f.list();
File [] fileObjects= f.listFiles();
for (int i = 0; i < fileObjects.length; i++) {
if(!fileObjects[i].isDirectory()){
String fname = file+fileNames[i];
out.println(fileNames[i]);
}
}
Then map this files to the JSP as links. When that link is clicked you can retrieve the actual path on the server when action is executed. What to do with the data, of course you can return stream result from the action that is used for streaming to the client browser. You can use docs examples from the Struts site or like in this example.
To navigate to the folder use parameters in GET request, that will be used to store current directory in session. You can change it if a user change the current directory from the view layer.
I have developed a grails app which has user file uploads (docs, etc..), they are stored in the relative folder "web-app/upload".
My question is that I do not know what is the best way to perform automatically war deployments and keep this folder. Because when I redeploy in Tomcat the whole app folder is deleted and all the files are deleted.
Additionaly I need a generic configuration fron set an external location from this Files
Have you found a solution for that?
P.D.: If I use System.properties['base.dir'] the result is null, and if I use a ApplicationHolder.application.mainContext.getResource() it return a temp path. :(
You should not be uploading files into your WAR structure. You should upload them to some external location.
I was able to solve partial as follow
//for development environment
def root = System.properties['base.dir']?.toString()
if(!root){
//for production environment in war deplements
def tmpRoot = ApplicationHolder.application.mainContext.getResource('WEB-INF').getFile().toString()
root = tmpRoot.substring(0, tmpRoot.indexOf(File.separator + 'temp' + File.separator))
}
if(!root){
throw new Exception('Not found a valid path')
}
return root + File.separator
I hope it can be useful to others
Regards,
Yecid PacĂfico
This code obtains the parent folder where the application is located:
String path = servletContext.getRealPath("/");
String parentStr = new File(path).getParentFile().getParent();
I mean, if the web application were located in D:\somefolder\myWeb
path would be D:\somefolder\myWeb\web-app
parentStr would be D:\somefolder
So you could save the files in D:\somefolder\files-outside-myWeb-context
Is it what you are looking for?