Web Connection
Request.GetMultiPartFiles() AngularJS Resource
Gravatar is a globally recognized avatar based on your email address. Request.GetMultiPartFiles() AngularJS Resource
  Harvey Mushman
  All
  Nov 29, 2016 @ 01:23pm

I just about have AngularJS Resource working with file uploads but I'm still having a problem when the client browser chooses to upload more than one file, a multiselect file upload.

On the client side I populate an object with the files and some other properties needed to keep track of what to do with the files on the server.. username, pk, xyz...

In this example, I select three files to upload from the browser. The array of file objects is passed in "files".

var loFile = {"tmpPk":123,"myFiles":files}

here is a screen shot of loFile.

Once it hits the server in VFP the collection only has one item, and the content of that item looks to be an array of [object File]... whatever that is?

where:

loFiles = REQUEST.GetMultiPartFiles("myfiles")
o=lofiles(1)

I'm only guessing, the problem is on the client and I need to convert the array of objects into an object of objects.

Anybody have a guess?

Gravatar is a globally recognized avatar based on your email address. re: Request.GetMultiPartFiles() AngularJS Resource
  Rick Strahl
  Harvey Mushman
  Nov 29, 2016 @ 04:51pm

How are you uploading the files?

If you're using some sort of upload control I would think it sends each file one at a time. So you get multiple requests to the same upload link.

If you're using regular HTML file elements that's when you end up with multiple files in a single request. Use Fiddler to check what goes over the wire. If multiple files go up you should see multiple file values in your mixed MIME content for the request data.

+++ Rick ---

Gravatar is a globally recognized avatar based on your email address. re: Request.GetMultiPartFiles() AngularJS Resource
  Harvey Mushman
  Rick Strahl
  Apr 29, 2017 @ 09:35am

Just getting back to this ongoing problem... -g-

Your last post here, you suggested looking at Fiddler, I have done that and determined the upload bits are getting passed back to the server.

But what I discovered after doing a number of divide byte count by two for each failure, is 4,193,806 fails and 4,193,805 works.

Here is my test data:

*** breaks ***
myFile = REPLICATE('X',4193806)
? STRTOFILE(myFile,'c:\temp\myByteCount.txt',0)

*** works ***
myFile = REPLICATE('X',4193805)
? STRTOFILE(myFile,'c:\temp\myByteCount.txt',0)

In addition to prove the point, I made the following two screen shots, breaks and works respectively:

Any suggestions about what can be done to get 16mg to upload?

Is there a setting in wc.ini or something simple that I have overlooked...

Gravatar is a globally recognized avatar based on your email address. re: Request.GetMultiPartFiles() AngularJS Resource
  Rick Strahl
  Harvey Mushman
  Apr 29, 2017 @ 10:28am

Not sure I understand. That code runs fine for me. You shouldn't see anything break in that STRTOFILE() code unless you create a string over 16 megs. Unless VFP doesn't have the memory to create the string.

+++ Rick ---

Gravatar is a globally recognized avatar based on your email address. re: Request.GetMultiPartFiles() AngularJS Resource
  Harvey Mushman
  Rick Strahl
  May 2, 2017 @ 09:33am

I don't think it is a stringToFile() issue.

wwServer.ProcessHit() does not seem to be passing the data through to wwRequest.InitializeRequest().

After a lot more tracing, I think the problem has to do with the request that is coming from Danial Farid's, AngularJS ng-file-upload routine.

There must be a CRTL-Z inserted although Fiddler does not show it... Both tests of working and broken files when the RAW text including the headers was compared in Beyond Compare were the same excluding WebKitFormBoundary tags and the filesize reference.

Typo in screen shot... route should read routine.

I'm sure there is an answer but I sure am having a hard time locating the cause of the problem. 😦

Any suggestions always welcome?

Gravatar is a globally recognized avatar based on your email address. re: Request.GetMultiPartFiles() AngularJS Resource
  Rick Strahl
  Harvey Mushman
  May 3, 2017 @ 01:43pm

Copy the file and try to create a simple repro case. IOW, catpure the input file and then try just on its own to pull the data in from there.

FREAD() shouldn't stop reading a file until there's a true EOF marker which should only exist at the end of the file.

+++ Rick ---

Gravatar is a globally recognized avatar based on your email address. re: Request.GetMultiPartFiles() AngularJS Resource
  Harvey Mushman
  Rick Strahl
  May 4, 2017 @ 06:24pm

Did as you suggested, copied the tmp file and sent you a copy through my gmail account along with the Fiddler request. Did you see it?

Gravatar is a globally recognized avatar based on your email address. re: Request.GetMultiPartFiles() AngularJS Resource
  Harvey Mushman
  Rick Strahl
  May 7, 2017 @ 08:54am

I've captured the tmp files that were created on a successful and failed attempt to upload an ascii text file using the Angular JS ng-file-upload module. These tests were created on my localhost server which is configured to use the dot NET handler.

The text file was created as shown above with REPLICATE('X', < byte count >) and then STRTOFILE()... where byte count was 4193813 = successful and 4193814 = failed.

The failed tmp file ends with the following text string, note nothing about the WebKitFormBoundary:

#@$ FORM VARIABLES $@#

The successful file contains both portions of my Request.GetMultipartFiles() my upload variables:

#@$ FORM VARIABLES $@#
------WebKitFormBoundaryPb8QaL5lb5lPLMtW
Content-Disposition: form-data; name="fields0"

{"pk":21,"targetkey":15,"targetpk":111,"rating":2,"title":"test","uploadtype":0,"expire":"2017-04-22T07:00:00Z","userpk":327,"filename":"4193813.txt","lastmodified":"2017-05-01T08:24:26-07:00","filesize":4193813}
------WebKitFormBoundaryPb8QaL5lb5lPLMtW
Content-Disposition: form-data; name="file"; filename="4193813.txt"
Content-Type: text/plain

XXXXXXXXXXXX... (redacted the text string of 'X' to post here)


Fiddler in both cases shows the data is being requested correctly.

For the record, I have tried switching the order of GetFormVarCollection() and GetMultipartFiles() but that had no affect. I fishing at this point...?

What other suggestions do you have to determining what I'm doing wrong or is it possible that this is a bug in the dot NET Handler?

Gravatar is a globally recognized avatar based on your email address. re: Request.GetMultiPartFiles() AngularJS Resource
  Harvey Mushman
  Harvey Mushman
  May 8, 2017 @ 04:48pm

Fixed... by following the directions found in the Web Connection Documentation

The IIS UI provided easy access through the web site "Request Filtering" interface. I set my upper limit to 15mb so I don't run into the 16mb limit of VFP. Doing this created the following xml in my web.config file.

<configuration>
    <system.webServer>
        <security>
          <requestFiltering>
            <requestLimits maxAllowedContentLength="150000000" />
          </requestFiltering>
        </security>
    <system.webServer>
</configuration>

Than I manually opened web.config and copied from the WC help file topic and set the maxRequestLength to match my 15mb limit.

<configuration>
    <system.web>
        <httpRuntime maxRequestLength="150000000"  executionTimeout="120" />
    </system.web>
<configuration>

Works like a charm! Thanks again Rick for your guidance.

Gravatar is a globally recognized avatar based on your email address. re: Request.GetMultiPartFiles() AngularJS Resource
  Rick Strahl
  Harvey Mushman
  May 8, 2017 @ 08:00pm

I guess this is one problem with having so much documentation. Nobody reads it 😃

Some creative searching would have found this tough:

I think if you search with West Wind Web Connection Documentation you're going to get pretty good result into the documentation. Or site:west-wind.com/webconnection/docs as a search postfix.

+++ Rick ---

Gravatar is a globally recognized avatar based on your email address. re: Request.GetMultiPartFiles() AngularJS Resource
  Harvey Mushman
  Rick Strahl
  May 9, 2017 @ 07:38am

Agreed, you will not get any complaints from me about the documentation (except for an occasional typo... < g >)!

However, either I need to get a lot smarter or the search engines need to do more AI before knowing what to search for produces the results you show above! I had no idea where the data was getting lost, on the client or server. So words like "Post Buffer" or even considering ASP.NET had any effect on Web Connect are both new news to me.

Let's face it, your depth and wealth of knowledge far exceeds any search engine today and you have the ability to read between the lines and as a result help in ways that no one else has been able to do.

© 1996-2024