Beispiel #1
0
        public static async Task <BITSUploadSession> Create(IFileProvider fileProvider, string fileName, long fragmentSizeLimit)
        {
            BITSUploadSession session = new BITSUploadSession(fileProvider, fileName, fragmentSizeLimit);

            if (await fileProvider.Exists(fileName))          // case the file already exists
            {
                if (await fileProvider.IsDirectory(fileName)) // case the file is actually a directory
                {
                    session._status_code = HttpStatusCode.Forbidden;
                }
                else if (SimpleBITSRequestHandler.Sessions.Any(_ => _.Value.FileName == fileName)) // case the file is being uploaded in another active session
                {
                    session._status_code = HttpStatusCode.Conflict;
                }
                else // case file exists on server - we overwrite the file with the new upload
                {
                    await session.OpenFile();
                }
            }
            else // case file does not exist but its parent folder does exist - we create the file
            {
                await session.OpenFile();
            }

            /*else // case file does not exist nor its parent folder - we don't create the directory tree
             *  session._status_code = HttpStatusCode.Forbidden;*/

            return(session);
        }
Beispiel #2
0
 Task <bool> TranscodeFileToFileProvider(BITSUploadSession session, IProgress <double> progress, CancellationToken ct) =>
 Task.Run(async() =>