I am doing a program to file-uplaod in the openshift. In this program I am upload whole files documents in the uploads folder, which is given default folder of the Openshift server.
I am using the file upload path
System.getenv("OPENSHIFT_DATA_DIR")
for upload files.
But I want to upload the file in my own project folder. I am created folder externally and I want to all the file in this folder.
$OPENSHIFT_DATA_DIR is the correct location for persistent data. If you upload to your $OPENSHIFT_REPO_DIR, subsequent git pushes will overwrite contents of with your local repo and the uploads will be lost.
If I'm misunderstanding your use case, please help me understand the reference to 'project folder' and 'created folder externally'. Feel free to share your use case on the OpenShift Forums as well: https://www.openshift.com/forums/openshift
Related
I am having problems with accessing file in public directory after deployment.
The stage command give me a folder target\universal\bin where my .exe file is.
In development mode I used to upload my files to public\uploads\pictures and access them from this location. But, after deployment I am unable to upload the pictures. I read this Stack Link that has two options. Is it possible to define a folder directory that is not absolute.
Application Conf
myUploadPath="public/Upload/Pictures/"
Accessing folder
String myUploadPath = Play.application().configuration()
.getString(myUploadPath);
Please tell me a solution to overcome this..
Found a solution
During development we are using public directory to store anything extras(in my case uploaded files) that we have. But, while deploying the application it is important that we change the reference to these extra files. I have changed the path from public directory to the absolute path of where the file is executed using
Play.application().path().getAbsolutePath()
and store the files in this directory.
If you don't want to use this than you can also specify an External Asset
I'm new to Cloudbees. I just opened an account and trying to upload a .JAR file which basically downloads a file to the location mentioned by user (through java command line arguments). So far I have run the .JAR in my local. So far, I was referring to my local file system to save the file. If I deploy my .JAR file to Cloudbees SDK, where can I save the downloaded file (and then process it).
NOTE: I know this is not a new requirement in java if we deploy the jar in UNIX/WINDOWS OS where we can refer the file system w.r.t to home directory.
Edit#1:
I've seen couple of discussions about the same topic.
link#1
link#2
Everywhere they are talking about the ephemeral (temporary) file system which we can access through System.getProperty("java.io.tempDir"). But I'm getting null when I access java.io.tempDir. Did anyone manage to save files temporarily using this tempDir?
You can upload a jar with the java stack specifying the class and classpath (http://developer.cloudbees.com/bin/view/RUN/Java+Container)
Our filesystem however is not persistent, so if you are talking about saving a file from within your application, you could save it in this path
System.getProperty("java.io.tmpdir")
but it will be gone when your application hibernates, scales-up/down or is redeployed.
If you want a persistent way to store file/images, you can use AmazonS3 from your cloudbees application: uploading your files there will ensure their persistence.
You can find an example of how to do that in this clickstart:
http://developer-blog.cloudbees.com/search?q=amazon+s3
More information here: https://wiki.cloudbees.com/bin/view/RUN/File+system+access
I have a desktop application which uploads files to an upload servlet. I want that uploaded files to be saved into a folder outside Tomcat, which is already mapped.
The url for the mapped folder is: "localhost:8080/MyApp/documents".
Physical path for the mapped folder is: /Users/gyo/Documents/MyApp/documents
Probably I'm making a newbie mistake but I would like to know: Is it possible to save the files in the mapped folder? If yes, how can I do that since servletContext.getRealPath("") is returning me the full path where the app is deployed?
Here is a link that explains how to upload files in Java running on tomcat and spring. Look for permissions on that folder "ls -ltr /folder-path/" to see owner and write permissions.
http://www.gingercart.com/Home/java-snippets/upload-images-java-code-example
Also look at java policies set on Tomcat for file/folder permissions at $CATALINA_BASE/conf/catalina.policy
I am using Spring framework MultipartFile to upload files using my application to the server, though whenever I do any 'Project > Clean' from Eclipse STS, all files I've uploaded earlier get deleted automatically.
I am saving all files uploaded to the following path:
String rootPath = request.getSession().getServletContext().getRealPath("contentrepository");
Which in real path get translated to:
C:\springsource\apache-tomcat-7.0.40\webapps\myapp\contentrepository\
so can someone please tell me what I am doing wrong here to cause those files to get deleted each time I do a Porject > Clean? Is it that STS clean command empty the webapps folder content? Shall I change the upload files folder location to another locations outside the apache folder totally?
Thanks or your time
Spring Multipart upload has nothing to do with your problem!
Whenever you clean your project, all deployed directories will be cleaned. Similarly, when you deploy your project, complied files will be deployed to server.
When you upload a file, it is save in your deployed location, however on cleaning all the data is lost.
If you want to persist file during your testing i.e want to have files even if you clean your project:
- Store uploaded file to some other location.
OR - Take backup of uploaded files before you clean your project and copy them to deployed folder.
You might like to view this question, for what exactly 'clean' does.
i want to download folder containing files like pdf,jpg,png etc from web services.I have written a application that can download pdf,png file.But i want to download folder containing several files. So my question is- is it possible to download folder and if yes then how can i download folder from server in android. thank you
If you can download one file, why wouldn't you be able to download several? Create the folder on Android, queue the files and start the next download when the current is finished, filling the folder. Also Android supports ZIP, so that might be your best call.
Folder is nothing but an FILE but a different type of file. Once you get the folder you can list down the files in it. You already have URL with the folder, u just need to append the URL of the folder to the files in it and download them one by one.