Revision history [back]

click to hide/show revision 1
initial version

asked 2021-03-15 16:59:00 +0800

Swarnaditya gravatar image Swarnaditya

How to obtain full file path without using FileUpload in zk

How do we get the full file path, without using FileUpload event? I searched the forums and it seems that the only way highlighted, is to first upload the media and then use media.getName(). But, if I just want to pass the file path rather than upload a 50 MB file, this adds a lot of overhead. How do I get the path without doing this? My current code is given below :-

<button hflex="1" upload="true, maxsize=-1, native" label="..." onupload="@command('onFileUpload')" disabled="@load(stepGeneralVM.isServerEntered)"/>

public void onFileUpload( @ContextParam(ContextType.BIND_CONTEXT) BindContext ctx) { UploadEvent upEvent = null; Object objUploadEvent = ctx.getTriggerEvent();

    if (objUploadEvent != null && (objUploadEvent instanceof UploadEvent)) {
        upEvent = (UploadEvent) objUploadEvent;

        Media media = upEvent.getMedia();

        byte[] bFile = media.getByteData();

        File myFile = new File(media.getName()); 
        setPackageSource(myFile.getAbsolutePath().toString());
        updateModelUi();
    }
}

Thanks in advance to any kind soul, who answers my query. Regards and have a nice day!

How to obtain full file path without using FileUpload in zk

How do we get the full file path, without using FileUpload event? I searched the forums and it seems that the only way highlighted, is to first upload the media and then use media.getName(). But, if I just want to pass the file path rather than upload a 50 MB file, this adds a lot of overhead. How do I get the path without doing this? My current code is given below :-

<button hflex="1" upload="true, maxsize=-1, native" label="..." onupload="@command('onFileUpload')" disabled="@load(stepGeneralVM.isServerEntered)"/>

public void onFileUpload( @ContextParam(ContextType.BIND_CONTEXT) BindContext ctx) { UploadEvent upEvent = null; Object objUploadEvent = ctx.getTriggerEvent();

    if (objUploadEvent != null && (objUploadEvent instanceof UploadEvent)) {
        upEvent = (UploadEvent) objUploadEvent;

        Media media = upEvent.getMedia();

        byte[] bFile = media.getByteData();

        File myFile = new File(media.getName()); 
        setPackageSource(myFile.getAbsolutePath().toString());
        updateModelUi();
    }
}

Thanks in advance to any kind soul, who answers my query. Regards and have a nice day!

How to obtain full file path without using FileUpload in zk

How do we get the full file path, without using FileUpload event? I searched the forums and it seems that the only way highlighted, is to first upload the media and then use media.getName(). But, if I just want to pass the file path rather than upload a 50 MB file, this adds a lot of overhead. How do I get the path without doing this? My current code is given below :-

<button hflex="1" upload="true, maxsize=-1, native" label="..." onupload="@command('onFileUpload')" disabled="@load(stepGeneralVM.isServerEntered)"/>

label = "..." onUpload="@command('onFileUpload')" disabled="@load(stepGeneralVM.isServerEntered)"/>


public void onFileUpload(
         @ContextParam(ContextType.BIND_CONTEXT)
         BindContext ctx) {
     UploadEvent upEvent = null;
     Object objUploadEvent = ctx.getTriggerEvent();

ctx.getTriggerEvent();

    if (objUploadEvent != null && (objUploadEvent instanceof UploadEvent)) {
        upEvent = (UploadEvent) objUploadEvent;

        Media media = upEvent.getMedia();

        File myFile = new File(media.getName()); 
        setPackageSource(myFile.getAbsolutePath().toString());
        updateModelUi();
    }
}

Thanks in advance to any kind soul, who answers my query. Regards and have a nice day!

How to obtain full file path without using FileUpload in zk

How do we get the full file path, without using FileUpload event? I searched the forums and it seems that the only way highlighted, is to first upload the media and media, then use media.getName(). media.getName(), and finally the getAbsolutePath() method. But, if I just want to pass have the file path rather than upload a 50 MB file, file to do just that, this obviously adds a lot of overhead. How do I get the path without doing this? uploading the corresponding file? My current code is given below :-

<button hflex="1" upload="true, maxsize=-1, native" label = "..."
        onUpload="@command('onFileUpload')"
        disabled="@load(stepGeneralVM.isServerEntered)"/>

public void onFileUpload(
        @ContextParam(ContextType.BIND_CONTEXT)
        BindContext ctx) {
    UploadEvent upEvent = null;
    Object objUploadEvent = ctx.getTriggerEvent();

    if (objUploadEvent != null && (objUploadEvent instanceof UploadEvent)) {
        upEvent = (UploadEvent) objUploadEvent;

        Media media = upEvent.getMedia();

        File myFile = new File(media.getName()); 
        setPackageSource(myFile.getAbsolutePath().toString());
        updateModelUi();
    }
}

Thanks in advance to any kind soul, who answers my query. Regards and have a nice day!

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More