0

File Transfer Success, but notification error

Hi,
I have want to implement File Transfer API,
- I have got notification fileTransferInvite,
- I have sent an Accept to v1/filetransfer/relay,
- i have got antother notification fileTransferSend,
- I have sent a Receive to v1/filetransfer/relay
- I connect to Relay IP provided, sent the token, receiver and sender
- I have got the File correctly
- BUT after that, I got another notification filetransfer with errorCode = -2

* after I receive the file, the YM that sent the file said "A problem occured while transfering the file XXX. The transfer has been stopped"

Does anyone can help me what I've done wrong here?

I tried to sent a Receive-Continue to v1/filetransfer/relay , after I receive the file, but with no luck.
For the relay server, I'm a little bit confused,
* did I have to connect to : http://ftrelay.messenger.yahooapis.com/relay and sent a header "Host: [relay IP given by fileTransferSend notification]
OR
* did I have to connect to : http:// [relay IP] / relay and sent a header "Host: ftrelay.messenger.yahooapis.com"
OR
* I dont have to sent a Host header ?

I've tried all of them with no luck, but It seems I can't change a host header in emulator I used.
Can anyone help me here?

Thank you very much.

by
12 Replies
  • Hello,

    I am using c# for Yahoo Messanger SDK. (400) Bad Request is coming when I send file to the contact

    Please can you describe me how can we send file to the contact .

    Thanks
    0
  • QUOTE (Mamta Yadav @ Sep 27 2010, 04:25 AM) <{POST_SNAPBACK}>
    Hello,

    I am using c# for Yahoo Messanger SDK. (400) Bad Request is coming when I send file to the contact

    Please can you describe me how can we send file to the contact .

    Thanks


    Sorry, I just finish the send file api
    you can send file to contact by send action=send
    "http://" + iServer + "/v1/filetransfer/relay"
    and POST data :
    "{\"sendAs\":\" + iPrimaryLoginID + "\",\"action\":\"invite\",\"ftSessionId\":\"" + sessionID +
    "\",\"target\":\"" + aYahooContact.iID + "\",\"files\":[{\"fileName\":\"" + filename + "\",\"fileSize\":" + size + "}]}";
    note that sessionID is a random number that we need to generate for send file

    then the target will be prompted that you want to send file blablabla

    when target is accept the file, we will get notification fileTransferInvite with action=3
    and you need to send to:

    "http://" + iServer + "/v1/filetransfer/relay"

    "{\"sendAs\":\" + iPrimaryLoginID + "\",\"action\":\"send\",\"ftSessionId\":\"" + sessionID +
    "\",\"target\":\"" + aYahooContact.iID + "\",\"fileName\":\"" + filename + "\",\"relayIP\":" + relayIP + "}";
    note: sessionID here is the one that we received from notification, and relayIP is IP from "ftrelay.messenger.yahooapis.com"

    then you will receive notification "fileTransferReceive"
    after receive this, we can upload the actual file to:

    * http:// [relayIP] / relay

    with POST data is the actual file

    Well, that's what I do and it's working ( I haven't test send file multiple files, I don't need it anyway ).

    The receive file still not working to me, have you tried it ?
    0
  • Hi,

    Thanks a lot for the code. I haven't receive file.
    I followed what you describe but still get the remote server returned an error: (403) Forbidden.

    Here is my code:-

    [code]
    string filename = "test"; also I assigned "test.txt"
    int size = 100;
    string sendFile_realm = "rcore1.messenger.yahooapis.com/v1/filetransfer/relay";

    string url = "http://" + sendFile_realm + "?&sid=" + sessionId + "&oauth_consumer_key=" + oauth_consumer_key + "&oauth_signature_method=" +
    oauth_signature_method + "&oauth_nonce=" + oauth_nonce + "&oauth_timestamp=" + oauth_timestamp + "&oauth_signature=" + oauth_signature
    + "&oauth_version=" + oauth_version + "&oauth_token=" + oauth_token;

    string postdata = "{\"sendAs\":\"" + iPrimaryLoginID + "\",\"action\":\"invite\",\"ftSessionId\":\"" + sessionID + "\",\"target\":\"" + aYahooContactID + "\",\"files\":
    [{\"fileName\":\"" + filename + "\",\"fileSize\":" + size + "}]}";

    string sessionid_request = fetchURL(url, true, postdata);

    public string fetchURL(string url, bool json, string postData)
    {

    StringBuilder sb = new StringBuilder();
    byte[] buf = new byte[8192];
    try
    {
    HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
    request.KeepAlive = true;

    if (json)
    {
    request.ContentType = "application/json; charset=utf-8";
    }
    if (postData != "")
    {
    request.Method = "Post";
    ASCIIEncoding encoding = new ASCIIEncoding();
    byte[] data = encoding.GetBytes(postData);
    request.ContentLength = data.Length;
    Stream newStream = request.GetRequestStream();
    newStream.Write(data, 0, data.Length);
    newStream.Close();
    }

    HttpWebResponse response = (HttpWebResponse)request.GetResponse();
    Stream resStream = response.GetResponseStream();

    string tempString = null;
    int count = 0;

    do
    {
    count = resStream.Read(buf, 0, buf.Length);
    if (count != 0)
    {
    tempString = Encoding.ASCII.GetString(buf, 0, count);

    sb.Append(tempString);
    }
    }
    while (count > 0);


    }
    catch (WebException e)
    {

    return "";
    }

    return sb.ToString();
    }

    [code]

    I don't know why it's coming even all the credentials are correct.
    Please guide me where I am doing mistake.


    Thanks
    Mamta
    0
  • Hi Mamta,
    did you use the API with signature method "Plain Text" ? Just wondering, because I didn't see any code for generating the signature for HMAC.
    FYI, I currently used HMAC method for sending file and it's working.
    0
  • i also get the same error..400. Can you show me your code, cantur?
    0
  • What do you mean by HMAC method?
    0
  • could you catur, explain again the part with send file ( not invite)? Thx
    0
  • how did you obtain notification fileTransferInvite? from web response?
    0
  • have a question. From where do I receive notification "fileTransferReceive" ( from v1/notifications , or from webresponse.
    Also where do I send the path pf the file I want to transfer?
    0
  • QUOTE (developer @ Mar 3 2011, 03:19 PM) <{POST_SNAPBACK}>
    have a question. From where do I receive notification "fileTransferReceive" ( from v1/notifications , or from webresponse.
    Also where do I send the path pf the file I want to transfer?


    1. Where you get the "fileTransferReceive" notification depends on your notification schema. If you are using periodic polling you will get it from <server>/v1/notifications. If you are using comet-style push, you will get it from <notification server>/v1/pushchannel/{primaryLoginId}. Please refer to http://developer.yahoo.com/messenger/guide...ationmanagement for more information
    2. You do not submit the file path in the file transfer handshake, just the filename
    0
  • where do I submit the file path? can u give me the steps of implementing file send? i do have te ssid from filetransferinvite. what do I do after that? can u give me an example of source code?
    thx
    0
  • from notification, i succeded to obtain filetransferinvite response. using this, and appealing again v1/notifications to obtain file transferreceive, i obtain again filetransferinvite. how do I get filetransferreceive? what is not ok?\
    string postdata = "{\"sendAs\":\"" + LoginID + "\",\"action\":\"send\",\"ftSessionId\":\"" + f_transfer + "\",\"target\":\"" + aYahooContactID + "\",\"fileName\":\"" + filename+ "\",\"relayIP\":" + relayIP + "}";

    ASCIIEncoding encoding = new ASCIIEncoding();
    byte[] x = encoding.GetBytes(postdata); from v1/notification i get again filetransferinvite instead of filtransfer receive. where do i encode the file ? what is not k?

    thx
    0

Recent Posts

in Messenger IM SDK