Problemas con el FTP al subir ficheros.

28/03/2007 - 15:47 por Diegoc | Informe spam
Hola, tengo un problema con la aplicación FTP que estoy creando.
Cuando me voy a conectar a mi servidor, me da un error 550 que dice
que el fichero no existe o esta protegido. Y efectivamente, el fichero
no existe, porque lo quiero crear.
El caso es que eso mismo lo ejecuto con el smartFTP, que es el
programa que utilizo para hacer mis envios. Y tambien da ese error,
pero luego lo arreglan haciendo algo, que no se lo que es.
Os mando el log, por si alguien me puede echar una mano. Quizá la
solución mas facil sea cambiar algo en el servidor, y no tengo ningun
problema, pero no se que!!!!
[15:40:40] Remote file exist check: "Folder.jpg".
[15:40:40] TYPE I
[15:40:40] 200 Type set to I.
[15:40:40] SIZE Folder.jpg
[15:40:40] 550 /c:/Folder.jpg: No such file.
[15:40:40] File size check (SIZE) failed. File not found or permission
denied.
[15:40:40] MODE S
[15:40:40] 200 MODE S ok.
[15:40:40] PASV
[15:40:40] 227 Entering Passive Mode (213,37,70,5,34,130)
[15:40:40] Opening data connection to 213.37.70.5 Port: 8834
[15:40:40] STOR Folder.jpg
[15:40:41] 150 Opening BINARY mode data connection for Folder.jpg.
[15:40:41] 10676 bytes transferred. (28,9 KB/s) (360 ms)
[15:40:42] 226 Transfer complete.
[15:40:42] MDTM 20070328085224 Folder.jpg
[15:40:42] 253 Date/time changed okay.
[15:40:42] SIZE Folder.jpg
[15:40:42] 213 10676
[15:40:42] TYPE A
[15:40:42] 200 Type set to A.
[15:40:42] MODE Z
[15:40:43] 200 MODE Z ok.
[15:40:43] PASV
[15:40:43] 227 Entering Passive Mode (213,37,70,5,34,131)
[15:40:43] Opening data connection to 213.37.70.5 Port: 8835
[15:40:43] MLSD
[15:40:43] 842 bytes transferred. (2,00 KB/s) (411 ms)
[15:40:43] 150 Opening BINARY mode data connection for MLSD.
[15:40:44] 226 Transfer complete.
[15:40:44] Transfer successful.


Gracias.
Diego

El codigo es
public static void Upload(string fileName, string uploadUrl)
{
Stream requestStream = null;
FileStream fileStream = null;
FtpWebResponse uploadResponse = null;
try
{
FtpWebRequest uploadRequest (FtpWebRequest)WebRequest.Create(uploadUrl);
uploadRequest.Method WebRequestMethods.Ftp.UploadFile;
uploadRequest.Credentials = new
NetworkCredential("xxxx", "xxxx");
uploadRequest.UsePassive = true;
uploadRequest.UseBinary = true;

// UploadFile is not supported through an Http proxy
// so we disable the proxy for this request.
uploadRequest.Proxy = null;

requestStream = uploadRequest.GetRequestStream();
fileStream = File.Open(fileName, FileMode.Open);

byte[] buffer = new byte[1024];
int bytesRead;
while (true)
{
bytesRead = fileStream.Read(buffer, 0,
buffer.Length);
if (bytesRead == 0)
break;
requestStream.Write(buffer, 0, bytesRead);
}

// The request stream must be closed before getting
// the response.
requestStream.Close();

uploadResponse (FtpWebResponse)uploadRequest.GetResponse();
Console.WriteLine("Upload complete.");
}
catch (UriFormatException ex)
{
Console.WriteLine(ex.Message);
}
catch (IOException ex)
{
Console.WriteLine(ex.Message);
}
catch (WebException ex)
{
Console.WriteLine(ex.Message);
}
finally
{
if (uploadResponse != null)
uploadResponse.Close();
if (fileStream != null)
fileStream.Close();
if (requestStream != null)
requestStream.Close();
}
}
Tambien lo he intentado asincrono, y na.
 

Leer las respuestas

#1 [Juanjo]
28/03/2007 - 17:35 | Informe spam
El log es del smartFTP no de tu funcion no?

Una pregunta:

En uploadURL estas pones la direccion del servidor FTP?? debes de poner
la direccion
del servidor y del nombre del fichero que quieres guardar, es decir:
uploadUrl="ftp.xxxxx.com/Folder.jpg";

Pruebalo a ver que sale.

Un saludo.

"Diegoc" escribió en el mensaje
news:
Hola, tengo un problema con la aplicación FTP que estoy creando.
Cuando me voy a conectar a mi servidor, me da un error 550 que dice
que el fichero no existe o esta protegido. Y efectivamente, el fichero
no existe, porque lo quiero crear.
El caso es que eso mismo lo ejecuto con el smartFTP, que es el
programa que utilizo para hacer mis envios. Y tambien da ese error,
pero luego lo arreglan haciendo algo, que no se lo que es.
Os mando el log, por si alguien me puede echar una mano. Quizá la
solución mas facil sea cambiar algo en el servidor, y no tengo ningun
problema, pero no se que!!!!
[15:40:40] Remote file exist check: "Folder.jpg".
[15:40:40] TYPE I
[15:40:40] 200 Type set to I.
[15:40:40] SIZE Folder.jpg
[15:40:40] 550 /c:/Folder.jpg: No such file.
[15:40:40] File size check (SIZE) failed. File not found or permission
denied.
[15:40:40] MODE S
[15:40:40] 200 MODE S ok.
[15:40:40] PASV
[15:40:40] 227 Entering Passive Mode (213,37,70,5,34,130)
[15:40:40] Opening data connection to 213.37.70.5 Port: 8834
[15:40:40] STOR Folder.jpg
[15:40:41] 150 Opening BINARY mode data connection for Folder.jpg.
[15:40:41] 10676 bytes transferred. (28,9 KB/s) (360 ms)
[15:40:42] 226 Transfer complete.
[15:40:42] MDTM 20070328085224 Folder.jpg
[15:40:42] 253 Date/time changed okay.
[15:40:42] SIZE Folder.jpg
[15:40:42] 213 10676
[15:40:42] TYPE A
[15:40:42] 200 Type set to A.
[15:40:42] MODE Z
[15:40:43] 200 MODE Z ok.
[15:40:43] PASV
[15:40:43] 227 Entering Passive Mode (213,37,70,5,34,131)
[15:40:43] Opening data connection to 213.37.70.5 Port: 8835
[15:40:43] MLSD
[15:40:43] 842 bytes transferred. (2,00 KB/s) (411 ms)
[15:40:43] 150 Opening BINARY mode data connection for MLSD.
[15:40:44] 226 Transfer complete.
[15:40:44] Transfer successful.


Gracias.
Diego

El codigo es
public static void Upload(string fileName, string uploadUrl)
{
Stream requestStream = null;
FileStream fileStream = null;
FtpWebResponse uploadResponse = null;
try
{
FtpWebRequest uploadRequest (FtpWebRequest)WebRequest.Create(uploadUrl);
uploadRequest.Method WebRequestMethods.Ftp.UploadFile;
uploadRequest.Credentials = new
NetworkCredential("xxxx", "xxxx");
uploadRequest.UsePassive = true;
uploadRequest.UseBinary = true;

// UploadFile is not supported through an Http proxy
// so we disable the proxy for this request.
uploadRequest.Proxy = null;

requestStream = uploadRequest.GetRequestStream();
fileStream = File.Open(fileName, FileMode.Open);

byte[] buffer = new byte[1024];
int bytesRead;
while (true)
{
bytesRead = fileStream.Read(buffer, 0,
buffer.Length);
if (bytesRead == 0)
break;
requestStream.Write(buffer, 0, bytesRead);
}

// The request stream must be closed before getting
// the response.
requestStream.Close();

uploadResponse (FtpWebResponse)uploadRequest.GetResponse();
Console.WriteLine("Upload complete.");
}
catch (UriFormatException ex)
{
Console.WriteLine(ex.Message);
}
catch (IOException ex)
{
Console.WriteLine(ex.Message);
}
catch (WebException ex)
{
Console.WriteLine(ex.Message);
}
finally
{
if (uploadResponse != null)
uploadResponse.Close();
if (fileStream != null)
fileStream.Close();
if (requestStream != null)
requestStream.Close();
}
}
Tambien lo he intentado asincrono, y na.

Preguntas similares