Hi Fold,

I got an issue with ch.ivyteam.ivy.scripting.objects.File.

When our Ivy application receive a file via SOAP with the same name all the time Ex: Information.html

We create a temporary file

ch.ivyteam.ivy.scripting.objects.File file = new ch.ivyteam.ivy.scripting.objects.File(path,true)

The problem happens is when 2 requests come at the same time, the second temporary file overrode the first one.

Is there any way to avoid it without change file name? or add subfolder (caseId) like IDocumentService in temporary file?

asked 22.11.2019 at 06:23

docvominh's gravatar image

docvominh
15459
accept rate: 0%

edited 25.11.2019 at 02:55

Reguel%20Wermelinger's gravatar image

Reguel Werme... ♦♦
9.4k21858


The path parameter is relative. So you can easily include more dynamic parts such as a folder:

e.g. new File(ch.ivyteam.util.GuidUtil.generateID()/fileName, true)

link

answered 25.11.2019 at 02:59

Reguel%20Wermelinger's gravatar image

Reguel Werme... ♦♦
9.4k21858
accept rate: 70%

Hi Reguel, Thank for your idea :)

Sadly, new File() with relative path didn't create folder, and I got file not found exception.

I must create a folder manually.

File folder = new File(GuidUtil.generateID(), true);
folder.mkdir();
File tempFile = new File(folder.getName() + "\\" + filename, true);

But problem solved :D

(25.11.2019 at 06:15) docvominh docvominh's gravatar image

If you use ch.ivyteam.ivy.scripting.objects.File it does not work? What method do you call afterwards to the tempFile?

(25.11.2019 at 06:55) Christian St... ♦ Christian%20Strebel's gravatar image

I try to write byte[] to that temp file

FileOutputStream fos = new FileOutputStream(tempFile.getJavaFile());

fos.write(fileData);

(28.11.2019 at 22:58) docvominh docvominh's gravatar image

at that's the issue: as soon as 'getJavaFile()' is called, the ivy File impl is no longer in charge to ensure that necessary parent dir structures are created. So you users have to do it manually - as you did.

(29.11.2019 at 05:45) Reguel Werme... ♦♦ Reguel%20Wermelinger's gravatar image
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "Title")
  • image?![alt text](/path/img.jpg "Title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×18

Asked: 22.11.2019 at 06:23

Seen: 352 times

Last updated: 29.11.2019 at 05:45