Chopping file while sending it via ASP response. Binary write

Source: Internet
Author: User
Chopping file while sending it via ASP response. Binary write

Hi everyone. I use ASP to send files to users to prevent hotlinking and I
Always used following Code

Response. contenttype = "Video/3GPP"
Response. addheader "content-disposition", "attachment; filename =" & file
&";"
Set objstream = server. Createobject ("ADODB. Stream ")
Objstream. Open
Objstream. type = 1
Objstream. loadfromfile "C: \ My. File"
Response. binarywrite objstream. Read
Objstream. Close
Set objstream = nothing

None of the files bigger than 4 MB. But today I have read following
(Couple posts below)

Sub sendfiletoresponse (filepath, filename)

Const clchunksize = 1048576 '1 MB

Dim ostream, I
Response. Buffer = false

Response. contenttype = "application/octet-stream"
Response. addheader "content-disposition ",_
"Attachment; filename =" & filename

Set ostream = server. Createobject ("ADODB. Stream ")
Ostream. type = 1' binary
Ostream. Open
Ostream. loadfromfile filepath

For I = 1 to ostream. Size \ clchunksize
Response. binarywrite ostream. Read (clchunksize)
Next
If (ostream. Size mod clchunksize) <0 then
Response. binarywrite ostream. Read (ostream. Size mod
Clchunksize)
End if
Ostream. Close

End sub

So my question is which one is better and more efficient? In my case only
Mobile phones used to download and I am not sure if copping files cocould
Couse problem.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.