Getting Error while uploading file on localhost using client application

Apr 29, 2015 at 6:54 AM
Hi,
  I  have two projects one is client side project and one is server side hssinterlink library project.I want to upload files from client to server and for that my client is communicating with server using webclient.UploadFile method.But i m getting internal server error plz let me know what i m doing wrong.This is my client side code-
fileName = @"D:\ms.jpg";
        String guid = Guid.NewGuid().ToString();
        string query = string.Empty;
        string httpmethod = null;
        string queryString = string.Empty;
        for (int i = 0; i < 4; i++)
        {
            string datetime = DateTime.Now.ToString("MM/dd/yyyy HH:mm:ss", System.Globalization.DateTimeFormatInfo.InvariantInfo);
            string method = null;
            if (i == 0)
            {
                method = "Prepare";
                httpmethod = "POST";
            }
            if (i == 1)
            {
                method = "CheckFileExists";
                httpmethod = "GET";
            }
            if (i == 2)
            {
                method = "NewFile";
                httpmethod = "GET";
            }
            if (i == 3)
            {

                method = "Append";
                httpmethod = "POST";
            }
            if (action == "download")
                queryString = datetime + ",DownloadHandler," + guid + "," + fileName + ","+ method +",Admin,Client1,1,1";
            else
                queryString = datetime + ",UploadHandler," + guid + "," + fileName + ","+ method +",Admin,Client1,1,1";

            byte[] qbytes = UTF8Encoding.UTF8.GetBytes(queryString);
            byte[] hashBytes = new System.Security.Cryptography.SHA1Managed().ComputeHash(qbytes);
            byte[] data = new byte[qbytes.Length + hashBytes.Length];
            Array.Copy(qbytes, data, qbytes.Length);
            Array.Copy(hashBytes, 0, data, qbytes.Length, hashBytes.Length);
            query = Convert.ToBase64String(data);
            string url = string.Empty;
            if (action == "download")
                url = "http://localhost:xxx/FileDownload.ashx?d=" + query;
            else
                url = "http://localhost:xxx/FileUpload.ashx?u=" + query;

            Uri uri = new Uri(url);

            if (action == "download")
            {

            }
            else
            {


                WebClient web = new WebClient();

                web.UploadFile(url,httpmethod, fileName);
            }
        }
Thanks
Apr 29, 2015 at 9:25 PM
You cannot use webClient.UploadFile with HSS Interlink. WebClient UploadFile is for sending a single file directly to your web server.

HSS Interlink uses a custom, multi-step process, for delivering one or more files (including large files), asynchronously, with support for retry, and chunking.

You'll have to recreate the HSS Interlink client side from the source code, or embed the Silverlight Client included with HSS Interlink, on your web page. Or if running as a process, then use the .NET Client.
Apr 30, 2015 at 10:01 AM
  Hi,   
                     Thanks for ur response.Now i m doing the same thing I am using http response for sending files as chunk to server. I am able to create a 0 kb file on server but when i m trying to append that file i m randomly getting error on tryparsequery function can u plz help me out.



Thanks
Apr 30, 2015 at 10:22 AM
Not sure what we can do to help you. The product is designed to work and provide the features as outlined on the product home page. Not sure what you're trying to accomplish by stripping out the client side code.

If you want to create a new "client" side that works with the existing server side, then I recommend you read thru the Client side code and understand the protocol, the multi-steps and how they work together. Then you can re-create the logic that already exist.

If you have a more specific question, we'd be more than happy to answer.
May 1, 2015 at 3:05 PM
Hi,

Thanks for ur response,I m trying to create new client that worked with the existing server side.I have undersand the protocol and using same code to connect to server .
But when i send query to server m getting error while parsing query "format exception" in parse query method of server.I m confused Is there any format to send query string to server.I m getting that error randomly.

plz help me out

thanks