ByteArray - accept very large data in POST/PUT request, ASP, VBScript

          Sample for ScriptUtils.ByteArray.SaveAs 

Examples
      You can use Post binary data to URL from WSH/ASP/VBA/VBS and Work with binary files in VBS - read and write local and remote files articles to read and send a binary file from a client-side.
ByteArray - accept very large data in POST/PUT request, ASP, VBScript 
<%
'This sample demonstrates store of large binary data.
'It accepts up to 2GB of a source data a PUT or POST 


SaveLargePostData "C:\temp\uploaddata.dat"

Sub SaveLargePostData(DestFile)
 Const BlockSize = 4096

 Dim TotalBytes, DataReaded, ReadBlockSize, BinaryData

 TotalBytes = Request.TotalBytes
 If TotalBytes > 0 Then
  Dim ByteArray: Set ByteArray = GetByteArray()
 
  For DataReaded = 0 To TotalBytes Step BlockSize
	
	If BlockSize + DataReaded > TotalBytes Then
	'Last block, IIS6 does not accept to read more data
		ReadBlockSize = TotalBytes - DataReaded
	Else
		ReadBlockSize = BlockSize 
	End If
	
	ByteArray.ByteArray = Request.BinaryRead(ReadBlockSize )

	'Save the block of a source data.
	If DataReaded = 0 Then
		'The first block will overwrite existing file (if one)
		ByteArray.SaveAs DestFile
	Else
		'Position of SaveAs (second parameter) is based to 1
		ByteArray.SaveAs DestFile, 1 + DataReaded
	End If
  Next ' DataReaded 
  Response.Write "<br>Source data (" & TotalBytes & _ 
   "B) was saved to '" & DestFile &  "'"
 End If ' TotalBytes>0 then
End Sub





'Returns ByteArray object. Solves problem with registration and installation
Function GetByteArray()
  On Error Resume Next
  Dim Binary
  Set Binary = CreateObject("ScriptUtils.ByteArray") 'Creates ByteArray object
  'response.write hex(Err)
  If Err = &h46 Then
    On Error Goto 0
    Err.Raise 5, "ScriptUtils.ByteArray", "Insufficient permissions to the scptult.ocx file. User: '" & GetUserName & "' must have read permission to the file."
  ElseIf Err = &h1ad Then
    On Error Goto 0
    Err.Raise 6, "ScriptUtils.ByteArray", "Script Utilities is not correctly installed. Please, install Script Utilities on this server or copy and register scptutl.ocx file on this server."
  ElseIf Err = &h8007045A Then
    On Error Goto 0
    Err.Raise 6, "ScriptUtils.ByteArray", "The evaluation version of Script Utilities was expired. Please install full version."
  ElseIf Err = &h8007007E Then
    On Error Goto 0
    Err.Raise 6, "ScriptUtils.ByteArray", "The ScriptUtilities library (scptutl.ocx) is missing. Please copy the library or reinstall the software."
  ElseIf Err <> 0 Then
    Dim E, N
    N = Hex(Err)
    E = Err.Description
    On Error Goto 0
    Err.Raise 6, "ScriptUtils.ByteArray", "Cannot create ScriptUtils.ByteArray object, Error: '" & N & " " & E & "'"
  End If
  Set GetByteArray = Binary
End Function

%>
  Other links for ByteArray - accept very large data in POST/PUT request, ASP, VBScript
Works with safearray binary data - save/restore binary data from/to a disk, convert to a string/hexstring, codepage/charset conversions, Base64 conversion, etc.
     ByteArray is a COM class specially designed to work with Microsoft Windows Scripting engines - VB Script and JScript in Active Server Pages or WSH and in CHM or HTA applications. It also works with VB Net, Visual basic (VBA - VB 5, VB 6, Word, Excel, Access, …), C#, J#, C++, ASP, ASP.Net, Delphi and with T-SQL OLE functions - see Use ByteArray object article. You can also use the object in other programming environments with COM support, such is PowerBuilder.
     Source code for ByteArray is available within distribution license, please see License page for ScriptUtilities and Huge ASP file upload.
      Easy to use, hi-performance ASP file upload component with progress bar indicator. Let's you upload multiple files with size up to 2GB to a disk or database along with another form fields. Works with large posts, any character set (including unicode utf-8). Contains one-click multiple files/folders download with on-the-fly compression (Using BinaryWrite/BinaryRead).
      Hi-performance text file logging for ASP/VBScript/VBA applications. Lets you create daily/weekly/monthly log files with variable number of logged values and extra timing and performance info.
       Lets you work with safearray binary data in VBS/JS. It also enables conversion between binary and String data using several code pages. ZLib compress and uncompress functions. Lets you transfer files using compressed stream from a client to server using IE.
      This library also enables calling of some Kernel and Advapi functions (performance, timing, sleep, configuration ...) and enables native work with INI files.


© 1996 – 2005 Motobit Software, help{at}pstruh.cz, help v. 2.16.14