Question about WebUploadedFile data

I just added that FileName = FileNames(0).ToText
Now the web page is throwing this up:

Stack:
rbframework.dylib$2159
String_ToText
String.$ToText%y%s
WebPageMain.WebPageMain.FilesUploadedMethod%%o<WebPageMain.WebPageMain>o<FileSelectContainerControl.FileSelectContainerControl>A1sA1v
Delegate.IM_Invoke%%o<FileSelectContainerControl.FileSelectContainerControl>A1sA1v
AddHandler.Stub.40%%A1sA1v
FileSelectContainerControl.FileSelectContainerControl.FileUploader_UploadComplete%%o<FileSelectContainerControl.FileSelectContainerControl>oA1o
Delegate.IM_Invoke%%oA1o
AddHandler.Stub.32%%A1o
WebFileUploader._SetFiles%%oA1o
WebSession._HandleRequest%i4%oso<_HTTPServer.HTTPRequestContext>
WebApplication._HandleHTTPRequest%%oo<_HTTPServer.HTTPRequestContext>
_HTTPServer.HTTPRequestThread.Event_Run%%o<_HTTPServer.HTTPRequestThread>
rbframework.dylib$1183
_pthread_body

Yeah, I just saw that. Well the filename coming from the web framework definitely has an encoding of Nil, so that’s the first problem. It should probably be coming to you as UTF8. If you simply do:

filename = DefineEncoding(filename,Encodings.UTF8)

this problem might just go away.

The minute I add that line Greg i get the exception thrown EVEN IN THE 32 Bit build.

[quote=268571:@Brian O’Brien]The thing I can’t understand is that the line
FileName = FileNames(0)[/quote]

Thats just assigning the first String in an array of Strings to a String Property of the same Method, that can’t be the problem, you’re getting an erroneous trigger there.

ok, try this.

Grab a hex editor for the mac, no idea what one is decent, dont use osx that much.

Check the line terminator in your file that you are uploading. If its 0D then stick with UNIX that isnt the problem. If its 0D0A then read on:

You have the following code in your example

rows = csvData.Split(EndOfLine.UNIX)//   Chr(&h0d))

Yet above you’re saying

That will mean you have 0A left over at the end of your strings after the split

Change the line above to:

rows = csvData.Split(EndOfLine.Windows)

See how that goes

@Brian, I’m not sure if the splitting of strings is your current issue but I’m sure 64-bit has that splitting strings problem.

Assuming ‘Content’ comes in as String, this pretty much how I unpack files.

  Dim Result As Text = Content.ToText
  
  // Process if we have results
  If Result.Length <> 0 Then
    
    Dim Lines() As Text
    Lines = Result.Split(Text.FromUnicodeCodepoint(10))
    
    // Parse Response
    Dim Delimiter As Text = "|"
    Dim Arr(-1) As Text
    For i As Integer = 0 To Lines.Ubound
      Redim Arr(-1)
      Dim Line As Text = Lines(i)
      Arr = Line.Split(Delimiter)
      
      //.. do something with Arr

I try to handle the encoding afterwards

Can you supply a text file with bogus information that has the same issue?

I think this is the only way we’re going to fix this tbh.

See if you can get us a 3-4 line file that throws the error on your machine.

@Julian. The issue is fixed.

The issue is that the file names that come from the WebFileUploader need to have their encodings DEFINED.

So in the FileAdded

Filename = DefineEncoding(Filename, Encodings.UTF8)

resolves the issue.

Thanks everyone… Glad to put that behind me.

Wow crazy that it was only showing up in x64 and only on the mac. Nice one Greg.

Just out of interest, did the file name have unicode in it as my demo worked on windows without funny chars in the filename.

[quote=268584:@Marco Hof]@Brian, I’m not sure if the splitting of strings is your current issue but I’m sure 64-bit has that splitting strings problem.

[snip]
I try to handle the encoding afterwards

Can you supply a text file with bogus information that has the same issue?[/quote]

The issue is fixed. And I did find the 64 bit documentation that recommended substituting Split for SplitB.