public SessionCreationStatusResponse StartSession([FromRoute] long userId,
                                                          [FromForm] CreateSessionParams sessionParams)
        {
            Session session = uploadService.createSession(userId, sessionParams.FileName,
                                                          sessionParams.ChunkSize.Value,
                                                          sessionParams.TotalSize.Value);

            return(SessionCreationStatusResponse.fromSession(session));
        }
Esempio n. 2
0
        public ActionResult <SessionCreationStatusResponse> StartSession(CreateSessionParams sessionParams)
        {
            if (sessionParams.TotalSize > 400 * 1024 * 1024)
            {
                return(BadRequest("Maximum File Size Is 400 Mb."));
            }

            var userId = HttpContext.User.Claims.First(c => c.Type == "sub").Value;

            Session session = UploadService.CreateSession(userId,
                                                          sessionParams.FileName,
                                                          sessionParams.TotalSize);

            return(SessionCreationStatusResponse.fromSession(session));
        }
Esempio n. 3
0
        public SessionCreationStatusResponse StartSession([FromRoute] long userId,
                                                          [FromForm] CreateSessionParams sessionParams)
        {
            InsertFileRequest request = new InsertFileRequest()
            {
                CreatedDate = DateTime.Now,
                IdUser      = 1,
                Name        = "Teste",
                Size        = 12213
            };
            var     response = _serviceFile.InsertFile(request);
            Session session  = uploadService.CreateSession(userId, sessionParams.FileName,
                                                           sessionParams.ChunkSize.Value,
                                                           sessionParams.TotalSize.Value);

            return(SessionCreationStatusResponse.fromSession(session));
        }
        public void TestChunkedUpload()
        {
            api          = new FileController();
            originalData = generateRandomArray(FILE_SIZE);
            string fileName = Guid.NewGuid().ToString();

            var parameters = new CreateSessionParams
            {
                FileName  = fileName,
                TotalSize = FILE_SIZE,
                ChunkSize = CHUNK_SIZE
            };

            SessionCreationStatusResponse session = createSession(parameters, api);

            for (int i = 0; i < NUMBER_OF_CHUNKS; i++)
            {
                uploadChunk(session.SessionId, i);
            }

            byte[] downloadedData = downloadFile(session.SessionId);

            Assert.Equal(SHAsum(originalData), SHAsum(downloadedData));
        }