• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
SOLVED : WOFileUpload and DefaultFileRenamePolicy
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

SOLVED : WOFileUpload and DefaultFileRenamePolicy


  • Subject: SOLVED : WOFileUpload and DefaultFileRenamePolicy
  • From: Erwin <email@hidden>
  • Date: Thu, 30 Dec 2004 15:58:52 +0100

I tried to ccatch an exception but unsuccessfully..
Finally I found a solution :

in the WOUpload component,
overwrite binding is set to 'true'
the 'streamToFilePath' binding is set to 'dynamicName'

then in my upload page java, I use :

import com.oreilly.servlet.multipart.*; // the cos package....
.......
public String aFileName;
protected String actualFilePath;
.....
public String dynamicName() {
DefaultFileRenamePolicy dfrp = new DefaultFileRenamePolicy();
File uploadedFile = dfrp.rename(new File(Application.fileUploadPath() + File.separator + NSPathUtilities.lastPathComponent(aFileName)));
return uploadedFile.getPath();
}

and I get what I need, files renamed when they have the same name, image.jpg, image1.jpg, image2.jpg etc.........
thanks

Erwin

Le Dec 30, 2004, à 2:38 PM, Wolfram Stebel a écrit :

Im not shure i understand what you did, but could it be a solution to run
into an exception by saving the second time, and to use the renamer in the
catch?

Wolfram Stebel
Flutgrabenstr. 19, 35576 Wetzlar
Tel. 06441/48164, Mobil: entfällt
Mailto: email@hidden



Von: Erwin <email@hidden>
Datum: Wed, 29 Dec 2004 17:36:57 +0100
An: "WebObjects (Group)" <email@hidden>
Betreff: WOFileUpload and DefaultFileRenamePolicy

Using WOFileUpload component, (WO5.3.2), I am trying to use the
DefaultFileRenamePolicy class (from the cos package -
com.oreilly.servlet)
to change the filename when it already exists (adding an integer at the
end... is the default policy)

DefaultFileRenamePolicy dfrp = new DefaultFileRenamePolicy();
....
File uploadedFile = dfrp.rename(new File(actualFilePath));

it's running well (creating image2.jpg, image3.jpg, etc...) excepted
during the first upload,
the later instruction is creating the first file : image.jpg and ALSO
the image1.jpg ...

I believe I rather should have 2 instructions , but I don't see how to
test which one to use in clickSubmitted

// for the 1st upload
File uploadedFile = new File(actualFilePath);
// and for the subsequent uploads...
File uploadedFile = dfrp.rename(new File(actualFilePath));


here is the .wod

FileName: WOString {
value = actualFilePath;
}

Form1: WOForm {
enctype = "multipart/form-data";
}

Hyperlink1: WOHyperlink {
action = returnToReferringPage;
}

ShowFile: WOConditional {
condition = hasFile;
}

SubmitButton1: WOSubmitButton {
action = submitClicked;
value = "Click here when done";
}

Upload1: WOFileUpload {
streamToFilePath = dynamicName;
finalFilePath = actualFilePath;
overwrite = false;
bufferSize = 2000;
filePath = aFileName;
size = "40";
mimeType = aMimeType;
}
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
d-errors.de

This email sent to email@hidden



 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Prev by Date: deploy Java Client
  • Next by Date: FYI: Possible buggy EOGenerator code?
  • Previous by thread: deploy Java Client
  • Next by thread: FYI: Possible buggy EOGenerator code?
  • Index(es):
    • Date
    • Thread