B4J Question [ABMATERIAL][ABMUpload] - problem multiparts

Roberto P.

Well-Known Member
Licensed User
Longtime User
Hi
I am using the ABMUpload control to import the files but they are saved with multipart format which i cannot open.

1588149296026.png

why?

I am using the ABMFeedback code

Thank
 
Multipart... is the result of the stream dump. Normally there should be code in your upload handler that would make a correct file from it:

Something like:
Code: Copy
...
data = req.GetMultipartData(downloadfolder, MaxSize)   
        Dim filePart As Part = data.Get("upl")           
        If filePart.IsInitialized Then
            fileName =     filePart.SubmittedFilename       
            tmpFileName = filePart.TempFile       
            If ABM.HandleUpload(downloadfolder, tmpFileName, fileName) Then   
                If SubExists(callback, "Page_FileUploaded") Then
                    CallSubDelayed3(callback, "Page_FileUploaded", fileName, True)
                End If
            Else
                If SubExists(callback, "Page_FileUploaded") Then           
                    CallSubDelayed3(callback, "Page_FileUploaded", fileName, False)
                End If
            End If   
...

Set a breakpoint in this routine an see what goes wrong.
 
Upvote 0
Multipart... is the result of the stream dump. Normally there should be code in your upload handler that would make a correct file from it:

Something like:
Code: Copy
...
data = req.GetMultipartData(downloadfolder, MaxSize)  
        Dim filePart As Part = data.Get("upl")          
        If filePart.IsInitialized Then
            fileName =     filePart.SubmittedFilename      
            tmpFileName = filePart.TempFile      
            If ABM.HandleUpload(downloadfolder, tmpFileName, fileName) Then  
                If SubExists(callback, "Page_FileUploaded") Then
                    CallSubDelayed3(callback, "Page_FileUploaded", fileName, True)
                End If
            Else
                If SubExists(callback, "Page_FileUploaded") Then          
                    CallSubDelayed3(callback, "Page_FileUploaded", fileName, False)
                End If
            End If  
...

Set a breakpoint in this routine an see what goes wrong.

I Alain,
this is my code

B4X: Copy
    Try
        data = req.GetMultipartData(downloadfolder, MaxSize)
                
        Dim filePart As Part = data.Get("upl")           
        If filePart.IsInitialized Then
            fileName =     filePart.SubmittedFilename
            tmpFileName = filePart.TempFile   
                
            If IsAllowed(fileName) = False Then
                File.Delete("", tmpFileName)
                If SubExists(callback, "Page_FileUploaded") Then           
                    CallSubDelayed3(callback, "Page_FileUploaded", fileName, False)
                End If
                'resp.SendError(500, "Not allowed")
                Return   
            End If           
            
            
        '    If Not(ABM.HandleUpload(downloadfolder, tmpFileName, ActiveCaseNumber & fileName)) Then   
                If SubExists(callback, "Page_FileUploaded") Then
                    CallSubDelayed3(callback, "Page_FileUploaded", fileName, True)
                End If
        '    Else
        '        If SubExists(callback, "Page_FileUploaded") Then           
        '            CallSubDelayed3(callback, "Page_FileUploaded", fileName, False)
        '        End If
        '    End If       
                
        Else ' try image

Could it be due to the increase in file size?

B4X: Copy
Public DownloadMaxSize As String = 5000 * 1024
 
Upvote 0
Ah OK

I deactivated because it often gives an error
 
Upvote 0
[CLOSE]

I resolved in this mode:

B4X: Copy
    'If Not(ABM.HandleUpload(downloadfolder, tmpFileName, ActiveCaseNumber & fileName)) Then   
            If True Then
                ' questa chiamatra trasforma il file multipart nel file normale. da lasciare assolutamente
                ABM.HandleUpload(downloadfolder, tmpFileName, ActiveCaseNumber & fileName)
                
                If SubExists(callback, "Page_FileUploaded") Then
                    CallSubDelayed3(callback, "Page_FileUploaded", fileName, True)
                End If
            Else
                If SubExists(callback, "Page_FileUploaded") Then           
                    CallSubDelayed3(callback, "Page_FileUploaded", fileName, False)
                End If
            End If
 
Upvote 0
One reason it may give an error is because you uploaded a file with a name that already exists in the folder. The rename of the second one will fail.


you cannot set a parameter to force overwriting or give an error message that the file is already present
 
Upvote 0
I don't think that's the problem because:
I reset the code and deleted all the files from the folder and table.
From error on the first attempt, if I try several times it works.
 
Upvote 0
Back
Top