| View previous topic :: View next topic |
| Author |
Message |
part_uploader
Joined: 05 Aug 2008 Posts: 39
|
Posted: Thu Aug 07, 2008 9:42 am Post subject: Partial file upload possible? |
|
|
Hi,
I want to use Jumploader as an uploading tool for a server-side metadata extractor. As the metadata is typically stored in the file header, only the first 50/100 KBytes of a file need to be uploaded (regardless of the true size).
Can I already customize Jumploader in this way or is this a new feature that has to be implemented to the Jumploader core?
Regards,
Franz |
|
| Back to top |
|
 |
jklam
Joined: 09 Nov 2007 Posts: 145
|
Posted: Thu Aug 07, 2008 11:06 am Post subject: |
|
|
Hi,
Have not tried it myself, but probably this should work:
- Code some JavaScript for "uploaderFileAdded(uploader, file)". When a file is added and file size is say > 200 KB, then call file.setLength(200 * 1024). This should cap the file length to 200 KB. |
|
| Back to top |
|
 |
yellowmosquito
Joined: 31 Oct 2007 Posts: 76
|
Posted: Fri Aug 08, 2008 3:17 pm Post subject: |
|
|
This idea is untested, but I thought it might be worth mentioning...
You can use the partitioned upload feature in conjunction with jklam's idea to just grab the first partition. Make sure your partition size is set to just grab as much as you need for the header (200*1024). Then you could set the javascript jklam posted below to run after that partition is recieved so that the transfer status shows as "complete".
One question though...why would you want to have a manual process for a server-side metadata extractor when you can write a fully automated process to do the same thing? These files are already on your server, right? |
|
| Back to top |
|
 |
part_uploader
Joined: 05 Aug 2008 Posts: 39
|
Posted: Fri Aug 08, 2008 7:45 pm Post subject: |
|
|
Thanks for your feedback! jklam's approach works fine for me, the first 200Kbytes are uploaded for each image. The only downside is that the images are marked as failed.
Following yellowmosquito's suggestions i tried the following code:
<!-- HTML HEADER GOES HERE -->
<script type="text/javascript">
function uploaderFileStatusChanged (uploader, file){
if (file.getUploadedPartitionCount() >= 1){
alert ("Partition Count > 1");
file.setLength(1);
}
}
</script>
<applet name="jumpLoaderApplet"
code="jmaster.jumploader.app.JumpLoaderApplet.class"
archive="static/jumploader_z.jar"
width="715"
height="500"
mayscript>
<param name="uc_imageEditorEnabled" value="true"/>
<param name="uc_uploaderFileStatusChanged" value="true"/>
<param name="uc_uploadUrl" value="upload"/>
<param name="uc_partitionLength " value="204800"/>
</applet>
<!-- HTML FOOTER GOES HERE -->
but the file.getUploadedPartitionCount()-condition is never true, so no action is performed. The files still appear as "failed" in the upload window.
Any suggestions? |
|
| Back to top |
|
 |
yellowmosquito
Joined: 31 Oct 2007 Posts: 76
|
Posted: Fri Aug 08, 2008 8:46 pm Post subject: |
|
|
Hmm,
Should you be using: file.setLength(204800);
rather than: file.setLength(1);
since it is in bytes?
If you change that, maybe you can trick jumploader into seeing it as a complete file. You might have to adjust the number of remaining partitions as well, but I don't know if that is possible. |
|
| Back to top |
|
 |
jklam
Joined: 09 Nov 2007 Posts: 145
|
Posted: Tue Aug 12, 2008 4:40 am Post subject: |
|
|
Hi,
If Jumploader still flags the files as failed, maybe you can do something like this:
1. On server upload script, when you have processed the file, return with a custom message like "Error: Done".
2. On the web page, handle the event "uploaderFileStatusChanged(uploader, file)". If file.getError() == "Error: Done", you can remove the file from the uploader with uploader.removeFile(file).
If the a different message shows for those "failed" files, you can modify step (2) accordingly. |
|
| Back to top |
|
 |
|