vertx.fileSystem().writeFile("/opt/myfile", data, new Handler<AsyncResult<Void>>() {
@Override
public void handle(AsyncResult<Void> ar) {
System.out.println("File is written: "+ar.cause());
}
});and I'm getting:
File is written: org.vertx.java.core.file.FileSystemException: java.nio.file.NoSuchFileException: /opt/myfile
File is written: org.vertx.java.core.file.FileSystemException: java.nio.file.NoSuchFileException: /opt/myfile
File is written: org.vertx.java.core.file.FileSystemException: java.nio.file.NoSuchFileException: /opt/myfile
File is written: org.vertx.java.core.file.FileSystemException: java.nio.file.NoSuchFileException: /opt/myfileBut if I change the path to the folder the module is running from, it creates the file with no problem.
I've check permissions, they are the same.
Should I be able to write outside the module folder? If not, why, and I really need it, so how can I do this?
Thanks,
Eugene
--
You received this message because you are subscribed to the Google Groups "vert.x" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vertx+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Hello,I'm trying to write a file:
vertx.fileSystem().writeFile("/opt/myfile", data, new Handler<AsyncResult<Void>>() {
@Override
public void handle(AsyncResult<Void> ar) {
System.out.println("File is written: "+ar.cause());
}
});
and I'm getting:
File is written: org.vertx.java.core.file.FileSystemException: java.nio.file.NoSuchFileException: /opt/myfile
File is written: org.vertx.java.core.file.FileSystemException: java.nio.file.NoSuchFileException: /opt/myfile
File is written: org.vertx.java.core.file.FileSystemException: java.nio.file.NoSuchFileException: /opt/myfile
File is written: org.vertx.java.core.file.FileSystemException: java.nio.file.NoSuchFileException: /opt/myfile
But if I change the path to the folder the module is running from, it creates the file with no problem.
I've check permissions, they are the same.
Should I be able to write outside the module folder? If not, why, and I really need it, so how can I do this?
Thanks,
Eugene
--
Yes, I was able to write to other locations, and further investigation shows, that I'm able to write to any folder as long as it exists.So, in my case if /opt folder is present, I can write file to it. If it doesn't exists, Vert.x doesn't create it for me and fails to write the file.
//Create all parent folders if needed
int ind=fileName.lastIndexOf('/');
if(ind>=0){
vertx.fileSystem().mkdirSync(fileName.substring(0, ind), true);
}
//write the file
vertx.fileSystem().writeFile(fileName, data, new Handler<AsyncResult<Void>>() {
@Override
public void handle(AsyncResult<Void> ar) {
System.out.println("File is written: "+ar.cause());
}
});
and everything works now.
BTW: the system is meant to hold a lot of traffic, so I'm trying to make everything as asynchronous as possible.
I wander if this:
vertx.fileSystem().writeFile(fileName, data, new Handler<AsyncResult<Void>>() {
@Override
public void handle(AsyncResult<Void> ar) {
//ignoring, have nothing to do here
}
});
would work the same as this:
vertx.fileSystem().writeFileSync(fileName, data);Or writeFileSync is actually blocking?
Thank you,
Eugene