ASP.NET Descargar de Otro ServerHola, a todo el mundoEstoy en un pequeño apuro y quisiera algunos consejos y ayudas concretas y rápidas, si se puede. Tengo el siguiente script, que sirve para descargar ficheros MP3 (evitando que se abran con el Media Player) y funciona muy bien. Sin embargo acabo de mover los ficheros MP3 del servidor de la página a otro servidor y quiero que cuando uno llame al script para descargarlos, éste los coja de ahí. El problema es que con el Server de ASP.NET solamente los descarga desde el servidor en el que está la página. ¿Qué tengo que hacer para que pueda leer la ruta del otro servidor, por ej. ' http://www.server2.com/arrchivos/cancion.mp3'? Este es el script:
000 001 002 003 004 005 006 007 008 009 010 011 012 013 014 015 016 017 018 019 020 021 022 023 024 025 026 027 028 029 030 031 032 033 034 035 036 037 038 039 040 041 042 043 044 045 046 047 048 049 050 051 052 053 054 055 056 057 058 059 060 061 062 063 064 065 066
|
<%@Language="VBScript"%> <%Option Explicit%> <%Response.Buffer = True%> <% On Error Resume Next Dim strPath strPath = CStr(Request.QueryString("url")) If strPath = "" Then Response.Clear Response.Write("No file specified.") Response.End ElseIf InStr(strPath, "..") > 0 Then Response.Clear Response.Write("Illegal folder location.") Response.End ElseIf Len(strPath) > 1024 Then Response.Clear Response.Write("Folder path too long.") Response.End Else Call DownloadFile(strPath) End If Private Sub DownloadFile(file) Dim strAbsFile Dim strFileExtension Dim objFSO Dim objFile Dim objStream strAbsFile = Server.MapPath(file) Set objFSO = Server.CreateObject("Scripting.FileSystemObject") If objFSO.FileExists(strAbsFile) Then Set objFile = objFSO.GetFile(strAbsFile) Response.Clear Response.AddHeader "Content-Disposition", "attachment; filename=" & objFile.Name Response.AddHeader "Content-Length", objFile.Size Response.ContentType = "application/octet-stream" Set objStream = Server.CreateObject("ADODB.Stream") objStream.Open objStream.Type = 1 Response.CharSet = "UTF-8" objStream.LoadFromFile(strAbsFile) do while not objStream.EOS Response.binarywrite objStream.Read(4194304) Response.Flush loop objStream.Close Set objStream = Nothing Set objFile = Nothing Else Response.Clear Response.Write("No such file exists.") End If Set objFSO = Nothing End Sub %>
|
Entonces, si la ruta (el strPath) es, por ejemplo " /ficheros/cancion.mp3" funciona pero si es " http://www.otroservidor.com/cancion.mp3" no funciona. ¡Muchas gracias y espero que hayais entendido todo el rollo! :!:
Preguntado hace 1309 dias
0 votos
|
 |
|
|
| |
|
Responder
No puedes responder, mensaje cerrado por inactividad