Download file with resteasy - file

I have a rest app with resteasy, which creates files and stores them and return the path, so I can see the name in the screen. The problem: When I want to download the file, I create the url with "app url" + "file path" but that doesn't work. The message is:
Could not find resource for relative : /publications_report_486.doc of full path:
http://127.0.0.1:8080/SIISA-Rest-0.6/publications_report_486.doc
In this example, I store the file in the app's root, so I just have to add the filename to the url.
I think resteasy is trying to find that url within their resources(services) and it doesn't find the path, so it doesn't access to the file, it just search the services.
How could I fix this?

I'm not sure how to return the file from within Resteasy - I've been looking for that myself which is how I stumbled across this, but you could probably deal with this particular problem by tweaking the your web.xml so that it doesn't include the location where you store your files in the servlet-mapping to Resteasy. You may want to have a look at the approach in this answer.

Related

Uploading files to a domain using form

I have written an application in CakePHP 3.x and there is a form to upload files.
At present, files are being uploaded to WWW_ROOT.'files' which is /app/webroot/files/ path.
To store files separately from core application, I created a subdomain cdn.example.com whose path is like /home/user/example.com/cdn.example.com/.
since, uploading files requires absolute path, how can I get absolute path of the subdomain cdn.example.com same as $_SERVER['DOCUMENT_ROOT']; from example.com?
First check if your server allow to write files from main domain to subdomain.
You can't get the absolute path of a different domain of the one you deployed your application, you should store the path in a variable or in constant.
If you really need to store files in another domain/subdomain and any path is blocked you should consider to reupload the files via FTP script.

angular file upload and preview

I am using ng-file-upload library to post files to my back end Web Api. Once the file is posted I save it to the following folder
"~/App_Data/Tmp/FileUploads/"
and also save the path to my database.
Now when I go on edit mode; I want to get a preview of all uploaded files (photos). But when I use something like
ng-src="path"
I get
"Not allowed to load local resource"
is this the right approach, when serving files from disk?
That path is a server path and not a client path so for sure that won't work.
You need to have an endpoint on your server to allow downloading those files with id or name/path and then set the src of the img to that url.
The implementation download endpoint depends on your backend technology.
If in your edit mode you still have access to the file object that use has just selected then you can do:
<img ngf-src="file">

GAE Yaml handler to use URLS

I have configured a bucket and to access the files uploaded here what should be the Yaml handler statement?
For example: http://commondatastorage.googleapis.com/yii2assets/e896c38e/css/bootstrap.css
When I browse this CSS file it prompts to download and looks it doesn’t understand the MIME type.
I can’t provide a static directory since it’s hosted on Google Storage and to access I need to use the URL mentioned above.
Please let me if you have any IDEAS.
What I need is a handle like:
url: bootstrap.css
script : URL FROM where TO SERVER
Like if I have to use a JQuery CDN URL.
You can upload static file with your code then config Yaml with static_files please see in doc.
If you want to upload file to Google Storage you can access by sending parameter from python to html file. It depend how you implement it Java, Python have a difference way to implement this.

XPages and Apache CXF: what's the best place for WSDL files?

I am currently testing Apache CXF (2.7.11). Purpose is to build a Web Service client. I am roughly following Martin Vereecken's blog post (http://www.bizzybee.be/2013/01/23/creating-a-java-webservice-client-in-domino-using-apache-cxf/#more-451). I have a WSDL file and I created sample code with the wsdl2java tool.
My first thought was to store the wsdl file in the NSF (e.g. WebContent\WEB-INF\resources\wsdl). However, the code generated does not seem to find the WSDL file. Code looks something like this (class name Session comes form the WSDL):
Session.java:
URL url = Session.class.getResource("WEB-INF/wsdl/twinfield/session.wsdl");
if (url == null) {
url = Session.class.getClassLoader().getResource("WEB-INF/wsdl/twinfield/session.wsdl");
}
I tried both WEB-INF and /WEB-INF but neither seem to work.
If I put the WSDL file on the web (e.g. domino/html/wsdl folder) the url above works, but the code breaks later (it seems that it uses java.io.File trying to load the WSDL).
Local reference (e.g. C:\temp\wsdl) could work but does not really sound like a robust option.
The final java code will be in WebContent\WEB-INF\src, not in Code\Java.
So, what is the "best practice" for storing and referencing WSDL files in Domino environment?
UPDATE
I went with #stwissel's proposal and noticed that the wsdl2java tool can actually create the whole jar for you. Just specify option -clientJar and the resulting JAR file will contain all class files + the wsdl file.
When you generate the Java classes from the WSDL, you should pack them into a JAR file. Put the WSDL into the Jar file, so it never gets lost. This blog article and the comments explain it.
A potential issue could be the access rights (Java execution permissions) when you keep that jar inside the NSF.
The blog entry contains the sample code, so check it out!

Can i use a centralized external config file for c#?

I found an article on using external config files here. While I was able to extract my config settings, I was unable to put them in a central location.
When i tried to do something like this:
<connectionStrings configSource="C:/dev/Configs/ConnectionStrings.config" />
It causes a type initializer exception. If i put the file in a folder under the bin directory, it's ok. Problem is, I want to keep the config files central to all apps so i can reuse it in a lot of places.
Is it just not doable?
I ended up using Symbolic Links. I created a subfolder under each app that symlinked back to the master config folder. All apps share the same Connection Strings now.

Resources