Beispiel #1
0
        protected async Task <string> PrepareAndSaveImage(IImageData source, CancellationToken cancelToken)
        {
            FileSaveInfo fileSaveInfo = new FileSaveInfo {
                FilePath    = WORKING_DIRECTORY,
                FilePattern = Path.GetRandomFileName(),
                FileType    = FileTypeEnum.FITS
            };

            return(await source.SaveToDisk(fileSaveInfo, cancelToken, forceFileType : true));
        }
        private async Task <JObject> SubmitImage(string session, IImageData source, CancellationToken cancelToken)
        {
            string filePath = null;

            try {
                FileSaveInfo fileSaveInfo = new FileSaveInfo {
                    FilePath    = WORKING_DIRECTORY,
                    FilePattern = Path.GetRandomFileName(),
                    FileType    = FileTypeEnum.FITS
                };

                filePath = await source.SaveToDisk(fileSaveInfo, cancelToken, forceFileType : true);

                using (var fs = new FileStream(filePath, FileMode.Open, FileAccess.Read)) {
                    return(await SubmitImageStream(fs, session, cancelToken));
                }
            } finally {
                if (filePath != null && File.Exists(filePath))
                {
                    File.Delete(filePath);
                }
            }
        }