Hi Daniel. First of all tank you for replying to my email.
I read that, but actually i donīt know where i supposed to write this flag.
I am doing this:
int enviar(LIBSSH2_SESSION *session, char* pathArchivoRemoto, char*
pathArchivoLocal)
{
LIBSSH2_SFTP_HANDLE *sftp_handle;
LIBSSH2_SESSION *sftp_session;
FILE* f;
int rc = 0, nread;
char *ptr;
LIBSSH2_SFTP_ATTRIBUTES atributos;
f = fopen(pathArchivoLocal, "r");
sftp_session = libssh2_sftp_init(session);
if (f == NULL)
{
return -1;
}
/* Request a file via SFTP */
sftp_handle =
libssh2_sftp_open(sftp_session,
pathArchivoRemoto,
LIBSSH2_FXF_WRITE|LIBSSH2_FXF_CREAT|*SSH_FXF_TEXT*,
LIBSSH2_SFTP_S_IRUSR|LIBSSH2_SFTP_S_IWUSR|
LIBSSH2_SFTP_S_IRGRP|LIBSSH2_SFTP_S_IROTH);
if (!sftp_handle) {
//ver que se hace
}
do {
char mem[1024];
nread = fread(mem, 1, sizeof(mem), f);
if (nread <= 0) {
break;
}
ptr = mem;
do {
/* write data in a loop until we block */
rc = libssh2_sftp_write(sftp_handle, ptr, nread);
if(rc < 0)
break;
ptr += rc;
nread -= rc;
} while (nread);
} while (rc > 0);
fclose(f);
libssh2_sftp_close(sftp_handle);
libssh2_sftp_shutdown(sftp_session);
libssh2_exit();
return 0;
}
where *SSH_FXF_TEXT is 0x00000040.
*
Thanks and best regards!*
*
2013/5/27 Daniel Stenberg <daniel_at_haxx.se>
> On Mon, 27 May 2013, Cristian Simonelli wrote:
>
> So the question is "How can i specify to the sftp server that the file is
>> a
>> text file?"
>>
>
> My best suggestion is the SSH_FXF_TEXT flag sent in the SSH_FXP_OPEN
> request, as per section 6.3.1 in draft-ietf-secsh-filexfer-05.**txt[*]
>
> (Later SFTP protocol versions seem to have a 'text-hint' that is
> different.)
>
> [*] =
> http://tools.ietf.org/wg/**secsh/draft-ietf-secsh-**
> filexfer/draft-ietf-secsh-**filexfer-05.txt<http://tools.ietf.org/wg/secsh/draft-ietf-secsh-filexfer/draft-ietf-secsh-filexfer-05.txt>
>
> --
>
> / daniel.haxx.se
> ______________________________**_________________
> libssh2-devel http://cool.haxx.se/cgi-bin/**mailman/listinfo/libssh2-devel<http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel>
>
_______________________________________________
libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel
Received on 2013-05-28