private async Task <SetupMsg> Setup(WebSocket ws)
        {
            var buf = new byte[256];
            // Read setup msg
            WebSocketReceiveResult result = await ws.ReceiveAsync(new ArraySegment <byte>(buf), CancellationToken.None);

            SetupMsg setupMsg = JsonConvert.DeserializeObject <SetupMsg>(Encoding.UTF8.GetString(buf, 0, result.Count));

            if (setupMsg.FileSize > UploadConfig.MaxFileSize)
            {
                await ws.CloseAsync(WebSocketCloseStatus.PolicyViolation, "File size too large",
                                    CancellationToken.None);

                throw new Exception("File size too large");
            }

            setupMsg.FileName = UploadUtil.SanitizeFileName(setupMsg.FileName);
            setupMsg.Code     = GetGuid();
            _dbHelper.InsertFilesEntry(Files.CreateWithUtcNow(setupMsg.Code, setupMsg.FileName, setupMsg.FileSize));
            await UploadUtil.SendResp(ws, Resp.Ok());

            return(setupMsg);
        }