{"action":"created","issue":{"url":"https://api.github.com/repos/nextcloud/windows-universal/issues/17","repository_url":"https://api.github.com/repos/nextcloud/windows-universal","labels_url":"https://api.github.com/repos/nextcloud/windows-universal/issues/17/labels{/name}","comments_url":"https://api.github.com/repos/nextcloud/windows-universal/issues/17/comments","events_url":"https://api.github.com/repos/nextcloud/windows-universal/issues/17/events","html_url":"https://github.com/nextcloud/windows-universal/issues/17","id":188622942,"number":17,"title":"Make included libraries universal","user":{"login":"SunboX","id":83344,"avatar_url":"https://avatars.githubusercontent.com/u/83344?v=3","gravatar_id":"","url":"https://api.github.com/users/SunboX","html_url":"https://github.com/SunboX","followers_url":"https://api.github.com/users/SunboX/followers","following_url":"https://api.github.com/users/SunboX/following{/other_user}","gists_url":"https://api.github.com/users/SunboX/gists{/gist_id}","starred_url":"https://api.github.com/users/SunboX/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SunboX/subscriptions","organizations_url":"https://api.github.com/users/SunboX/orgs","repos_url":"https://api.github.com/users/SunboX/repos","events_url":"https://api.github.com/users/SunboX/events{/privacy}","received_events_url":"https://api.github.com/users/SunboX/received_events","type":"User","site_admin":false},"labels":[{"id":478403618,"url":"https://api.github.com/repos/nextcloud/windows-universal/labels/1.%20to%20develop","name":"1. to develop","color":"0052cc","default":false},{"id":465533618,"url":"https://api.github.com/repos/nextcloud/windows-universal/labels/enhancement","name":"enhancement","color":"0e8a16","default":true},{"id":465533619,"url":"https://api.github.com/repos/nextcloud/windows-universal/labels/help%20wanted","name":"help wanted","color":"006b75","default":true}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2016-11-10T21:27:49Z","updated_at":"2016-11-29T17:45:28Z","closed_at":null,"body":"To make this app a universal app (UWP) we need to fix the included libraries `WebDavClient` and `NextcloudClient`. Both use the `Windows.Web.Http.HttpClient` that is platform dependent. \r\n\r\nI had to use the HttpClient, because Windows Mobile caches the uploading files while it is uploading them. HttpClient accepts a `HttpBaseProtocolFilter` object that has a `CacheControl.WriteBehavior` property you can set to `HttpCacheWriteBehavior.NoCache`.\r\n\r\nAt first I used `System.Net.WebRequest`, which would be universal available. I tried to get the upload progress like this:\r\n\r\n```csharp\r\nvar uploadFileRequest = WebRequest.Create(_uri) as HttpWebRequest;\r\nuploadFileRequest.Method = \"PUT\";\r\nuploadFileRequest.ContentType = _file.ContentType;\r\nuploadFileRequest.Headers[\"Pragma\"] = \"no-cache\";\r\nuploadFileRequest.Headers[\"Content-Length\"] = stream.Size.ToString();\r\nvar stream = await _file.OpenAsync(FileAccessMode.ReadWrite);\r\nusing (var inputStream = stream.GetInputStreamAt(0))\r\n{\r\n    using (var dataReader = new Windows.Storage.Streams.DataReader(inputStream))\r\n    {\r\n        const int chunkSize = 256;\r\n        var req = await uploadFileRequest.GetRequestStreamAsync();\r\n        do\r\n        {\r\n            var read = await dataReader.LoadAsync(chunkSize);\r\n            var buffer = new byte[read];\r\n            dataReader.ReadBytes(buffer);\r\n            await req.WriteAsync(buffer, 0, (int)read);\r\n            await req.FlushAsync(); // flushing is required or else we jump to 100% very fast\r\n            BytesSend += (int)read;\r\n        } while (BytesSend < BytesTotal);\r\n        await uploadFileRequest.GetResponseAsync();\r\n        var response = (HttpWebResponse) await uploadFileRequest.GetResponseAsync();\r\n        var result = new HttpResponseMessage(response.StatusCode);\r\n        result.Content = new StreamContent(response.GetResponseStream());\r\n    }\r\n}\r\n```\r\n\r\nIt will show a progress, but after it reaches 100% it takes more or less the same time to finish. This is because Windows Mobile caches the upload stream while it get's send. So you can only measure the time taken to write this file stream into the send cache of the OS.\r\n\r\nSadly, by now I have not found any way to implement a correct upload progress as windows universal. Maybe someone has an idea how it would work or want's to try out some things?\r\n\r\nThe only solution I can imagine for now is to implement a file upload method for every platform. But this isn't very nice. 😏 "},"comment":{"url":"https://api.github.com/repos/nextcloud/windows-universal/issues/comments/263643537","html_url":"https://github.com/nextcloud/windows-universal/issues/17#issuecomment-263643537","issue_url":"https://api.github.com/repos/nextcloud/windows-universal/issues/17","id":263643537,"user":{"login":"SunboX","id":83344,"avatar_url":"https://avatars.githubusercontent.com/u/83344?v=3","gravatar_id":"","url":"https://api.github.com/users/SunboX","html_url":"https://github.com/SunboX","followers_url":"https://api.github.com/users/SunboX/followers","following_url":"https://api.github.com/users/SunboX/following{/other_user}","gists_url":"https://api.github.com/users/SunboX/gists{/gist_id}","starred_url":"https://api.github.com/users/SunboX/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SunboX/subscriptions","organizations_url":"https://api.github.com/users/SunboX/orgs","repos_url":"https://api.github.com/users/SunboX/repos","events_url":"https://api.github.com/users/SunboX/events{/privacy}","received_events_url":"https://api.github.com/users/SunboX/received_events","type":"User","site_admin":false},"created_at":"2016-11-29T17:45:28Z","updated_at":"2016-11-29T17:45:28Z","body":"So now only the NextcloudCLient should be made universal and than I think we are mostly done. (except some small UI changes)\r\n\r\nThanks @DecaTec for your great work! ❤️ "}}
{"actor":{"display_login":"SunboX"}}