NetTalk Central

Author Topic: file upload problems  (Read 6050 times)

cwtart

  • Full Member
  • ***
  • Posts: 130
    • View Profile
    • CommPay Software
    • Email
file upload problems
« on: July 09, 2013, 08:18:56 AM »
NT 7.11

I am uploading files from a form - multiple-file select using the advanced HTML5 option. The user may select only one file to upload or as many as 10-15 or more at one time. These files are mostly .jpg and tif but could be any file type.

With each file that uploads I need to process that file in the "3 SaveFile Routine" embed. The processing takes a bit of time - each file is renamed, run through a couple of ImageEx classes, moved to another folder, and then a parent .tps record is created to attach the file to a specific invoice record.

All files are uploading correctly to the web/uploads folder but my processing is failing - I think because of timing issues. My processing appears to be out of sync with the arrival of the files in the upload folder and some errors are occurring - such as rename or copy failures.

If I upload all the selected files one at a time by clicking the individual start button on the file list everything works fine - but if I click Start for all files at once then the problems arise.

Am I using the wrong embed to do this? I have put a one second delay timer in the SaveFile embed but that does not prevent the problem.

If I do not use a one second delay timer in the SaveFile routine I get exceptions related to file access that crash the web server app.

Need some help - thanks.

Chuck


DonRidley

  • Don Ridley
  • Global Moderator
  • Hero Member
  • *****
  • Posts: 729
  • donaldridley2011@gmail.com
    • View Profile
    • Email
Re: file upload problems
« Reply #1 on: July 09, 2013, 10:34:28 AM »
Hello Chuck,

I believe there were some upload issues with 7.11.  I would recommend that you update to 7.14 or wait for the upcoming 7.15.  That might solve your issue.

Don
"Eliminate the impossible, whatever remains, however unlikely, must be the truth."

NetTalk 12.55
Clarion 11

cwtart

  • Full Member
  • ***
  • Posts: 130
    • View Profile
    • CommPay Software
    • Email
Re: file upload problems
« Reply #2 on: July 09, 2013, 12:04:33 PM »
Don,

Kinda scary upgrading after looking at all the bug reports <g>

I am also having display problems with mobile on file upload - the "start" button overlays the "select" button.

Do you know any of the specifics of the upload problems?

Chuck

cwtart

  • Full Member
  • ***
  • Posts: 130
    • View Profile
    • CommPay Software
    • Email
Re: file upload problems
« Reply #3 on: July 09, 2013, 02:44:03 PM »
Upgrade to NT 7.14 no help - app still crashes with exception as long as I am doing any file processing in SaveFile routine.

Chuck

cwtart

  • Full Member
  • ***
  • Posts: 130
    • View Profile
    • CommPay Software
    • Email
Re: file upload problems
« Reply #4 on: July 09, 2013, 03:03:08 PM »
Here's a strange twist - if I compile and run the app in debug mode it does not crash when I upload multiple files with a single start click.

Chuck

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: file upload problems
« Reply #5 on: July 10, 2013, 03:57:02 AM »
Hi Chuck,

If I had to guess I'd say your embed code is not "thread-safe".

When multiple files are uploaded, each file is uploaded onto a separate thread. This is because (as you can see in the log) they come in as separate requests.

Thus all the code in your embed code should be "thread-safe" meaning that it might be running 10 times "at the same time" and it should be ok. Obviously this then extends to the image library you are using as well.

It's hard to comment further on specifics without seeing the specific code you are embedding - but hopefully this points you in the right direction.

cwtart

  • Full Member
  • ***
  • Posts: 130
    • View Profile
    • CommPay Software
    • Email
Re: file upload problems
« Reply #6 on: July 10, 2013, 04:13:11 AM »
Bruce,

That makes sense - I will move the SaveFile embeded code to a separate procedure and Start() the procedure and see what happens.

Chuck

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: file upload problems
« Reply #7 on: July 10, 2013, 06:44:08 AM »
I don't think either of those things will help - if the code is already not thread-safe then putting it in another thread won't make it better.
But worth a try I suppose.

cheers
Bruce

cwtart

  • Full Member
  • ***
  • Posts: 130
    • View Profile
    • CommPay Software
    • Email
Re: file upload problems
« Reply #8 on: July 11, 2013, 02:54:24 AM »
Bruce,

Ultimately, I could not get the classes I am using to be thread safe so I had to settle on allowing the user to select only one file at a time.

Maybe on the wish list here - the option to have multiple selected files upload serially rather than on multiple threads at the same time.

Thanks for your help.

Chuck

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: file upload problems
« Reply #9 on: July 11, 2013, 04:52:49 AM »
Hi Chuck,

unfortunately it's not possible to serialize them. That's not the way HTML works.

What you can do of course is just add the name to a file, and then one a separate thread process the incoming files one at a time.
That way all the processing is only done on one thread.

cheers
Bruce


Rob Kolanko

  • Sr. Member
  • ****
  • Posts: 253
    • View Profile
Re: file upload problems
« Reply #10 on: July 11, 2013, 05:19:39 AM »
Hi Chuck,
Here is a thought, would it be possible to allow the user to upload all the files first. Then when the user press the button to accept the window, process the uploaded files as a batch.
Rob

cwtart

  • Full Member
  • ***
  • Posts: 130
    • View Profile
    • CommPay Software
    • Email
Re: file upload problems
« Reply #11 on: July 12, 2013, 07:45:12 AM »
Rob,

I need to track an invoice number for each file as the files are uploaded so waiting until all files are uploaded would not allow me to know which file should be attached to which invoice.

Plus, I could not rely on the user to click the proper button to close the upload form. But thanks.

Chuck

bshields

  • Sr. Member
  • ****
  • Posts: 392
    • View Profile
    • Inhabit
    • Email
Re: file upload problems
« Reply #12 on: July 18, 2013, 06:42:03 PM »
Hi Chuck,

ImageEx is not threadsafe. I use it for image processing in a fashion similar to what you have explained.

I just wrapped the call into the function i needed of ImageEx in a critical section. Alternatively i could have "queued" via a threadsafe means the necessary information and then sequentially processed the queue.

Regards
Bill