Tuesday, January 24, 2017

Trying to save user profile picture does not work this way


I have an app where each user can have a profile picture. When the user first registers a new standard profile picture will be set for him which will be editable. So I am creating the profile picture after the registration as shown below:

String femalePicture = System.getProperty("user.dir") + "/images/icons/female.png";
String malePicture = System.getProperty("user.dir") + "/images/icons/male.png";

String userDirectory = userDetails.getUsername().replaceAll("\\.", "");
String destination = System.getProperty("user.dir") + "/files/profile_pictures/" + userDirectory + ".png";

File destinationFile = new File(destination);
if (destinationFile.getParentFile() != null) {

if (userDetails.getGender().equals("Female")) {
Files.copy(new File(femalePicture).toPath(), destinationFile.toPath(), StandardCopyOption.REPLACE_EXISTING);
} else {
Files.copy(new File(malePicture).toPath(), destinationFile.toPath(), StandardCopyOption.REPLACE_EXISTING);

Basically it copies an existing image (male or female) from a already existing folder on the server to another folder but with a different name which corresponds to a modified username.

The problem I am facing here is that the image will be deleted when I restart/recompile the GWT application, since the data is only on the server.

How can I get this working? What are my solutions to the problem described above?

Thanks in advance

You received this message because you are subscribed to the Google Groups "GWT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at https://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment