|
 |
aspx thread: HELP ME!!!
Message #1 by "Betti Alessandro" <betti@g...> on Tue, 8 Oct 2002 18:04:26 +0200
|
|
I have an application in ASP that write a BLOB in a DB (for example .doc
.ppt .xsl)
the proplem is when i get .ZIP and i make Response.BinaryWrite .
The Download from DB is right but when i try to open the .ZIP file WINZIP
tell me that the file is corrupt .
I know there is some problem with CRC code but ther is something that i can
do?
Thank you
Betti Alessandro
Message #2 by Imar Spaanjaars <Imar@S...> on Tue, 08 Oct 2002 18:09:43 +0200
|
|
How about you post some of your ASP code so we can take a look at it.
Cheers,
Imar
At 06:04 PM 10/8/2002 +0200, you wrote:
>I have an application in ASP that write a BLOB in a DB (for example .doc
>.ppt .xsl)
>the proplem is when i get .ZIP and i make Response.BinaryWrite .
>The Download from DB is right but when i try to open the .ZIP file WINZIP
>tell me that the file is corrupt .
>I know there is some problem with CRC code but ther is something that i can
>do?
>
>Thank you
>Betti Alessandro
Message #3 by "Betti Alessandro" <betti@g...> on Tue, 8 Oct 2002 18:32:53 +0200
|
|
Ok . I use for Upload thi function that take file from post method
--------------------------------------------------------------------------
Sub BuildUploadRequest(RequestBin)
'Get the boundary
PosBeg = 1
PosEnd = InstrB(PosBeg,RequestBin,getByteString(chr(13)))
boundary = MidB(RequestBin,PosBeg,PosEnd-PosBeg)
boundaryPos = InstrB(1,RequestBin,boundary)
'Get all data inside the boundaries
Do until (boundaryPos=InstrB(RequestBin,boundary & getByteString("--")))
'Members variable of objects are put in a dictionary object
Dim UploadControl
Set UploadControl = CreateObject("Scripting.Dictionary")
'Get an object name
Pos = InstrB(BoundaryPos,RequestBin,getByteString("Content-Disposition"))
Pos = InstrB(Pos,RequestBin,getByteString("name="))
PosBeg = Pos+6
PosEnd = InstrB(PosBeg,RequestBin,getByteString(chr(34)))
Name = getString(MidB(RequestBin,PosBeg,PosEnd-PosBeg))
PosFile = InstrB(BoundaryPos,RequestBin,getByteString("filename="))
PosBound = InstrB(PosEnd,RequestBin,boundary)
'Test if object is of file type
If PosFile<>0 AND (PosFile<PosBound) Then
'Get Filename, content-type and content of file
PosBeg = PosFile + 10
PosEnd = InstrB(PosBeg,RequestBin,getByteString(chr(34)))
FileName = getString(MidB(RequestBin,PosBeg,PosEnd-PosBeg))
'Add filename to dictionary object
UploadControl.Add "FileName", FileName
Pos = InstrB(PosEnd,RequestBin,getByteString("Content-Type:"))
PosBeg = Pos+14
PosEnd = InstrB(PosBeg,RequestBin,getByteString(chr(13)))
'Add content-type to dictionary object
ContentType = getString(MidB(RequestBin,PosBeg,PosEnd-PosBeg))
UploadControl.Add "ContentType",ContentType
'Get content of object
PosBeg = PosEnd+4
PosEnd = InstrB(PosBeg,RequestBin,boundary)-2
Value = MidB(RequestBin,PosBeg,PosEnd-PosBeg)
Else
'Get content of object
Pos = InstrB(Pos,RequestBin,getByteString(chr(13)))
PosBeg = Pos+4
PosEnd = InstrB(PosBeg,RequestBin,boundary)-2
Value = getString(MidB(RequestBin,PosBeg,PosEnd-PosBeg))
End If
'Add content to dictionary object
UploadControl.Add "Value" , Value
'Add dictionary object to main dictionary
UploadRequest.Add name, UploadControl
'Loop to next object
BoundaryPos=InstrB(BoundaryPos+LenB(boundary),RequestBin,boundary)
Loop
End Sub
----------------------------------------------------------------------------
--------
After i use that code to push out the blob
----------------------------------------------------------------------------
-----------
set Obj = server.CreateObject(X)
ares = Obj.GetDBRecordArray
ares = Obj.GetByID (X)
session("X") = ares(I TAKE A BLOB)
session("X_FILENAME") =ares(I TAKE FILE NAME)'
Response.Buffer = true
Response.Clear
if not IfZIP then
Response.contentType = "application/"+GetContentType(X)
else
Response.AddHeader "content-disposition","attachment; filename=" +
session("X_FILENAME")
Response.contentType
"application/x-zip-compressed"'"application/"+GetContentType(X)
end if
if not IsNull(session("X")) then
Response.binarywrite session("X")
end if
ares = null
Response.End
----------------------------------------------------------------------------
---------------------------
Best Regards
Betti Alessandro
----- Original Message -----
From: "Imar Spaanjaars" <Imar@S...>
To: "ASP+" <aspx@p...>
Sent: Tuesday, October 08, 2002 6:09 PM
Subject: [aspx] Re: HELP ME!!!
> How about you post some of your ASP code so we can take a look at it.
>
>
> Cheers,
>
> Imar
>
>
> At 06:04 PM 10/8/2002 +0200, you wrote:
> >I have an application in ASP that write a BLOB in a DB (for example .doc
> >.ppt .xsl)
> >the proplem is when i get .ZIP and i make Response.BinaryWrite .
> >The Download from DB is right but when i try to open the .ZIP file
WINZIP
> >tell me that the file is corrupt .
> >I know there is some problem with CRC code but ther is something that i
can
> >do?
> >
> >Thank you
> >Betti Alessandro
>
>
>
> ---
>
> ASP.NET 1.0 Namespace Reference with C#
> http://www.wrox.com/acon11.asp?ISBN=1861007442
>
> ASP.NET 1.0 Namespace Reference with VB.NET
> http://www.wrox.com/acon11.asp?ISBN=1861007450
>
> These books are a complete reference to the ASP.NET namespaces
> for developers who are already familiar with using ASP.NET.
> There is no trivial introductory material or useless .NET
> hype and the presentation of the namespaces, in an easy-to use
> alphabetical order ensures a user-friendly reference format.
> We provide in-depth coverage of all the major ASP.NET classes,
> giving you those real-world tips that the documentation doesn't
> offer, and demonstrating complex techniques with simple
> examples.
>
> ---
Message #4 by Imar Spaanjaars <Imar@S...> on Tue, 08 Oct 2002 18:46:09 +0200
|
|
Are you sure the page that is serving the BLOB does not contain anything
else than the Response.BinaryWrite method?
Even a space in the ASP(X) page can cause this behavior.
Also, it seems not very useful to first store the BLOB in a Session, and
then Response it out. Why don't you do this directly?? What kind of Server
Object are you creating to retrieve the data from the database.
Server.CreateObject(X) is not very descriptive to this forum.....
And last but not least, this all looks like classic ASP to me. Why are you
posting in the ASPX forum? You may have more luck in the ASP lists.....
Cheers,
Imar
At 06:32 PM 10/8/2002 +0200, you wrote:
>Ok . I use for Upload thi function that take file from post method
>--------------------------------------------------------------------------
>Sub BuildUploadRequest(RequestBin)
> 'Get the boundary
> PosBeg = 1
> PosEnd = InstrB(PosBeg,RequestBin,getByteString(chr(13)))
> boundary = MidB(RequestBin,PosBeg,PosEnd-PosBeg)
> boundaryPos = InstrB(1,RequestBin,boundary)
> 'Get all data inside the boundaries
> Do until (boundaryPos=InstrB(RequestBin,boundary & getByteString("--")))
> 'Members variable of objects are put in a dictionary object
> Dim UploadControl
> Set UploadControl = CreateObject("Scripting.Dictionary")
> 'Get an object name
> Pos = InstrB(BoundaryPos,RequestBin,getByteString("Content-Disposition"))
> Pos = InstrB(Pos,RequestBin,getByteString("name="))
> PosBeg = Pos+6
> PosEnd = InstrB(PosBeg,RequestBin,getByteString(chr(34)))
> Name = getString(MidB(RequestBin,PosBeg,PosEnd-PosBeg))
> PosFile = InstrB(BoundaryPos,RequestBin,getByteString("filename="))
> PosBound = InstrB(PosEnd,RequestBin,boundary)
> 'Test if object is of file type
> If PosFile<>0 AND (PosFile<PosBound) Then
> 'Get Filename, content-type and content of file
> PosBeg = PosFile + 10
> PosEnd = InstrB(PosBeg,RequestBin,getByteString(chr(34)))
> FileName = getString(MidB(RequestBin,PosBeg,PosEnd-PosBeg))
> 'Add filename to dictionary object
> UploadControl.Add "FileName", FileName
> Pos = InstrB(PosEnd,RequestBin,getByteString("Content-Type:"))
> PosBeg = Pos+14
> PosEnd = InstrB(PosBeg,RequestBin,getByteString(chr(13)))
> 'Add content-type to dictionary object
> ContentType = getString(MidB(RequestBin,PosBeg,PosEnd-PosBeg))
> UploadControl.Add "ContentType",ContentType
> 'Get content of object
> PosBeg = PosEnd+4
> PosEnd = InstrB(PosBeg,RequestBin,boundary)-2
> Value = MidB(RequestBin,PosBeg,PosEnd-PosBeg)
> Else
> 'Get content of object
> Pos = InstrB(Pos,RequestBin,getByteString(chr(13)))
> PosBeg = Pos+4
> PosEnd = InstrB(PosBeg,RequestBin,boundary)-2
> Value = getString(MidB(RequestBin,PosBeg,PosEnd-PosBeg))
> End If
> 'Add content to dictionary object
> UploadControl.Add "Value" , Value
> 'Add dictionary object to main dictionary
> UploadRequest.Add name, UploadControl
> 'Loop to next object
> BoundaryPos=InstrB(BoundaryPos+LenB(boundary),RequestBin,boundary)
> Loop
>
>End Sub
>----------------------------------------------------------------------------
>--------
>
>After i use that code to push out the blob
>
>----------------------------------------------------------------------------
>-----------
>
> set Obj = server.CreateObject(X)
>
> ares = Obj.GetDBRecordArray
> ares = Obj.GetByID (X)
> session("X") = ares(I TAKE A BLOB)
> session("X_FILENAME") =ares(I TAKE FILE NAME)'
> Response.Buffer = true
> Response.Clear
>
> if not IfZIP then
> Response.contentType = "application/"+GetContentType(X)
> else
> Response.AddHeader "content-disposition","attachment; filename=" +
>session("X_FILENAME")
> Response.contentType
>"application/x-zip-compressed"'"application/"+GetContentType(X)
> end if
>
> if not IsNull(session("X")) then
> Response.binarywrite session("X")
> end if
> ares = null
> Response.End
>----------------------------------------------------------------------------
>---------------------------
>
>Best Regards
>Betti Alessandro
>
>----- Original Message -----
>From: "Imar Spaanjaars" <Imar@S...>
>To: "ASP+" <aspx@p...>
>Sent: Tuesday, October 08, 2002 6:09 PM
>Subject: [aspx] Re: HELP ME!!!
>
>
> > How about you post some of your ASP code so we can take a look at it.
> >
> >
> > Cheers,
> >
> > Imar
> >
> >
> > At 06:04 PM 10/8/2002 +0200, you wrote:
> > >I have an application in ASP that write a BLOB in a DB (for example .doc
> > >.ppt .xsl)
> > >the proplem is when i get .ZIP and i make Response.BinaryWrite .
> > >The Download from DB is right but when i try to open the .ZIP file
>WINZIP
> > >tell me that the file is corrupt .
> > >I know there is some problem with CRC code but ther is something that i
>can
> > >do?
> > >
> > >Thank you
> > >Betti Alessandro
> >
Message #5 by "Betti Alessandro" <betti@g...> on Tue, 8 Oct 2002 19:10:19 +0200
|
|
Ok ... i have ask to ASP Forum but anyone give me a solution .
I try ASPX that i know there are also a good programmer in this forum ...or
not?
However i mantain a BLOB in session because i need in many operation and i
don't wont to take it all the time.
Object X come from MTS and is businness logic that help me to retrive data.
Tanks
Betti Alessandro
Message #6 by Imar Spaanjaars <Imar@S...> on Tue, 08 Oct 2002 19:23:43 +0200
|
|
OK, so the same applies:
Make sure there is NO white space or other output in your page.
If that doesn't help, I think the error is somewhere in your business logic
component. Maybe you should post some relevant code of that as well.
I personally think you need to clean up your code a little, and make things
more clear and explicit.
For example, how about this:
ares = Obj.GetDBRecordArray
ares = Obj.GetByID (X)
No, what exactly is ares? First it's Obj.GetDBRecordArray , then it's
Obj.GetByID (X) So, IMO, the first calls seems unnecessary, unless
Obj.GetDBRecordArray is doing something required by Obj.GetByID (X) which
would defeat the "rules" of stateless components in MTS / COM+
What I would do is this:
1. Don't use a database, but store the files on disk. Just safe a reference
to the file in the database.
2. Don't use a Session object to store (large) BLOBs. I don't know how
large the BLOBs are, or how many users you have, but this is definitely one
of the best ways to bring your server to a grinding halt if there are too
many users.
3. If you save your files on disk, there is no need to store them in a
Session anymore. Simply pass around the file reference, and
Response.BinaryWrite them to the browser. IMO, this is a fast and reliable
/ stable solution.
I agree it's tempting to store the files in the database: first of all you
have everything nicely packed together, and secondly: it looks cool ;-)
However, storing your stuff on disk my actually proof to be more useful
(faster backups, Indexing etc etc)
Cheers,
Imar
At 07:10 PM 10/8/2002 +0200, you wrote:
>Ok ... i have ask to ASP Forum but anyone give me a solution .
>I try ASPX that i know there are also a good programmer in this forum ...or
>not?
>
>However i mantain a BLOB in session because i need in many operation and i
>don't wont to take it all the time.
>
>Object X come from MTS and is businness logic that help me to retrive data.
>
>Tanks
>Betti Alessandro
Message #7 by "Joel Hartshorn" <joelha@d...> on Thu, 10 Oct 2002 11:16:40 -0700
|
|
Hello,
I ran into a similar issue. Try forcing the content type and filename like so:
Response.ContentType = "Application/zip";
Response.AppendHeader("content-disposition", "attachment; filename=" + strFileName.ToString());
Thanks,
Joel
---------- Original Message ----------------------------------
From: Imar Spaanjaars <Imar@S...>
Reply-To: "ASP+" <aspx@p...>
Date: Tue, 08 Oct 2002 19:23:43 +0200
>OK, so the same applies:
>
>Make sure there is NO white space or other output in your page.
>
>If that doesn't help, I think the error is somewhere in your business logic
>component. Maybe you should post some relevant code of that as well.
>
>I personally think you need to clean up your code a little, and make things
>more clear and explicit.
>
>For example, how about this:
>
>ares = Obj.GetDBRecordArray
>ares = Obj.GetByID (X)
>
>No, what exactly is ares? First it's Obj.GetDBRecordArray , then it's
>Obj.GetByID (X) So, IMO, the first calls seems unnecessary, unless
>Obj.GetDBRecordArray is doing something required by Obj.GetByID (X) which
>would defeat the "rules" of stateless components in MTS / COM+
>
>What I would do is this:
>
>1. Don't use a database, but store the files on disk. Just safe a reference
>to the file in the database.
>2. Don't use a Session object to store (large) BLOBs. I don't know how
>large the BLOBs are, or how many users you have, but this is definitely one
>of the best ways to bring your server to a grinding halt if there are too
>many users.
>3. If you save your files on disk, there is no need to store them in a
>Session anymore. Simply pass around the file reference, and
>Response.BinaryWrite them to the browser. IMO, this is a fast and reliable
>/ stable solution.
>
>I agree it's tempting to store the files in the database: first of all you
>have everything nicely packed together, and secondly: it looks cool ;-)
>
>However, storing your stuff on disk my actually proof to be more useful
>(faster backups, Indexing etc etc)
>
>Cheers,
>
>Imar
>
>
>
>
>At 07:10 PM 10/8/2002 +0200, you wrote:
>>Ok ... i have ask to ASP Forum but anyone give me a solution .
>>I try ASPX that i know there are also a good programmer in this forum ...or
>>not?
>>
>>However i mantain a BLOB in session because i need in many operation and i
>>don't wont to take it all the time.
>>
>>Object X come from MTS and is businness logic that help me to retrive data.
>>
>>Tanks
>>Betti Alessandro
>
>
>
>---
>
>ASP.NET 1.0 Namespace Reference with C#
>http://www.wrox.com/acon11.asp?ISBN=1861007442
>
>ASP.NET 1.0 Namespace Reference with VB.NET
>http://www.wrox.com/acon11.asp?ISBN=1861007450
>
>These books are a complete reference to the ASP.NET namespaces
>for developers who are already familiar with using ASP.NET.
>There is no trivial introductory material or useless .NET
>hype and the presentation of the namespaces, in an easy-to use
>alphabetical order ensures a user-friendly reference format.
>We provide in-depth coverage of all the major ASP.NET classes,
>giving you those real-world tips that the documentation doesn't
>offer, and demonstrating complex techniques with simple
>examples.
>
>---
>
|
|
 |