<html>
  <head>
    <meta content="text/html; charset=windows-1252"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    Hello,<br>
    <br>
    Check out
    <a class="moz-txt-link-freetext" href="https://github.com/owncloud/pyocclient/blob/master/owncloud/owncloud.py#L457">https://github.com/owncloud/pyocclient/blob/master/owncloud/owncloud.py#L457</a>
    for how to do it properly.<br>
    <br>
    You need to pass a magic file name (file name + a bunch of stuff
    embedded in the file name) to make it work.<br>
    <br>
    Cheers,<br>
    <br>
    Vincent<br>
    <br>
    <div class="moz-cite-prefix">On 07.06.2015 11:22, RAHUL JAIN wrote:<br>
    </div>
    <blockquote
cite="mid:CALzrpovCEoTopqk4KBa6qH8TDyoL6D=3W2QpVkuao8W_5pCL2g@mail.gmail.com"
      type="cite">
      <pre wrap="">Hi All,

I am trying to upload file in chunks on ownCloud on-premise server using
ASP.NET C#. I have tried all my ways to upload file in chunks but each time
my chunk data is overwrite on previous chunk data.

I am unable to append my chunk on previously uploaded chunk. I am using
plUpload to send files in chunk. And i have created an handler which is
called each time a chunk is uploaded here is the code that runs to upload
the chunk. I know i am missing some headers to inculde in code which must
be required to submit data in chunks.
Below is my code to submit data on ownCloud server.

Source code used:

public void Upload(Stream chunkStream, String remoteFilePath, object state)
        {
            Uri uploadUri = getServerUrl(remoteFilePath, false);
            string method = WebRequestMethods.Http.Put.ToString();

            var content = ReadFully(chunkStream);

            AsyncCallback callback = new AsyncCallback(FinishUpload);

            // Need to send along headers?
            IDictionary<string, string> headers = new Dictionary<string,
string>();
            headers.Add("OC_Chunked", "1");

            HTTPRequest(uploadUri, method, headers, content, localFilePath,
callback, state, true);
        }

void HTTPRequest(Uri uri, string requestMethod, IDictionary<string, string>
headers, byte[] content, string uploadFilePath, AsyncCallback callback,
object state, bool sendChunks)
        {
            httpWebRequest = (HttpWebRequest)HttpWebRequest.Create(uri);

            /*
             * The following line fixes an authentication problem explained
here:
             *
<a class="moz-txt-link-freetext" href="http://www.devnewsgroups.net/dotnetframework/t9525-http-protocol-violation-long.aspx">http://www.devnewsgroups.net/dotnetframework/t9525-http-protocol-violation-long.aspx</a>
             */
            System.Net.ServicePointManager.Expect100Continue = false;

            // The server may use authentication
            if (user != null && pass != null)
            {
                NetworkCredential networkCredential;
                if (domain != null)
                {
                    networkCredential = new NetworkCredential(user, pass,
domain);
                }
                else
                {
                    networkCredential = new NetworkCredential(user, pass);
                }
                httpWebRequest.Credentials = networkCredential;
                // Send authentication along with first request.
                httpWebRequest.PreAuthenticate = true;
            }
            httpWebRequest.Method = requestMethod;


            // httpWebRequest.SendChunked = true;
            if (headers != null)
            {
                foreach (string key in headers.Keys)
                {
                    httpWebRequest.Headers.Set(key, headers[key]);
                }
            }

            if (sendChunks)
            {
                httpWebRequest.SendChunked = true;
            }

            // Need to send along content?
            if (content != null || uploadFilePath != null)
            {
                RequestState asyncState = new RequestState();
                asyncState.request = httpWebRequest;
                asyncState.userCallback = callback;
                asyncState.userState = state;

                if (content != null)
                {
                    // The request either contains actual content...
                    httpWebRequest.ContentLength = content.Length;
                    asyncState.content = content;
                    httpWebRequest.ContentType = "text/xml";
                }
                else
                {
                    // ...or a reference to the file to be added as content.
                    httpWebRequest.ContentLength = new
FileInfo(uploadFilePath).Length;
                    asyncState.uploadFilePath = uploadFilePath;
                }

                // Retrieve the request stream.
                Stream putRequestStream1 =
httpWebRequest.GetRequestStream();

                // Write the string to the destination as text bytes.
                putRequestStream1.Write(content, 0, content.Length);

                // Close the request stream.
                putRequestStream1.Close();

                // Retrieve the response.
                HttpWebResponse httpPutResponse1 =
(HttpWebResponse)httpWebRequest.GetResponse();
            }
            else
            {
            }
        }


Kindly suggest where am i doing wrong.

Thanks in advance.

</pre>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <br>
      <pre wrap="">_______________________________________________
Devel mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Devel@owncloud.org">Devel@owncloud.org</a>
<a class="moz-txt-link-freetext" href="http://mailman.owncloud.org/mailman/listinfo/devel">http://mailman.owncloud.org/mailman/listinfo/devel</a>
</pre>
    </blockquote>
    <br>
  </body>
</html>