Exemple #1
0
        /// <inheritdoc />
        public async Task SaveAsync(byte[] data, ImageToken imageToken)
        {
            var path = CreateImagePath(imageToken);

            if (File.Exists(path))
            {
                using (var writer = new FileStream(path, FileMode.Truncate))
                {
                    await writer.WriteAsync(data, 0, data.Length);
                }
            }
            else
            {
                var fileInfo = new FileInfo(path);
                if (!fileInfo.Directory.Exists)
                {
                    fileInfo.Directory.Create();
                }

                using (var writer = new FileStream(path, FileMode.CreateNew))
                {
                    await writer.WriteAsync(data, 0, data.Length);
                }
            }
        }
Exemple #2
0
 /// <inheritdoc />
 public string CreateImagePath(ImageToken imageToken)
 {
     return(FilePathHelper.GetPath("Images", imageToken.PathSanitized));
 }