user3152495
user3152495

Reputation: 1

File upload in OpenShift

I am making an application which will save user uploads (files) in server. When I deploy the application in localhost it runs well, but now I want to do the same in OpenShift.

The path were the files are being saved in my local host is Savefile = "D:/Test/" + Userid + "/" + Savefile + "/";

How do I change this path in my application after deploying in OpenShift so that it works?

Upvotes: 0

Views: 4165

Answers (2)

Micha F.
Micha F.

Reputation: 634

Run this code once to check if there is a default data-directory. If it exists use it as data directory.

String property = System.getProperty("jboss.server.data.dir");
if (property != null) {
    boolean exists = new File(property).exists();
    System.out.println("exists: " + exists); // if the file exists you can use it as data directory for your uploads
}

Upvotes: 0

TheSteve0
TheSteve0

Reputation: 3526

you want to grab the environment variable

$OPENSHIFT_DATA_DIR

in your code and then write to that path (if you want to keep the file).

If it is only temporary then you can write to /tmp

Upvotes: 7

Related Questions