Пример #1
0
 public void AddImageToCache(CachedImageResult cachedImage, byte[] buffer)
 {
     if (PrepareAddImageToCache(cachedImage, buffer))
     {
         // save file
         _fileSystem.WriteAllBytes(BuildPath(cachedImage.Path), buffer);
     }
 }
Пример #2
0
        public void Save(MediaItem media, byte[] data)
        {
            Guard.NotNull(media, nameof(media));

            // TODO: (?) if the new file extension differs from the old one then the old file never gets deleted

            var filePath = GetPicturePath(media);

            if (data != null && data.LongLength != 0)
            {
                _fileSystem.WriteAllBytes(filePath, data);
            }
            else if (_fileSystem.FileExists(filePath))
            {
                _fileSystem.DeleteFile(filePath);
            }
        }
        public void Save(MediaFile mediaFile, byte[] data)
        {
            Guard.NotNull(mediaFile, nameof(mediaFile));

            // TODO: (?) if the new file extension differs from the old one then the old file never gets deleted

            var filePath = GetPath(mediaFile);

            if (data != null && data.LongLength > 0)
            {
                _fileSystem.WriteAllBytes(filePath, data);
            }
            else if (_fileSystem.FileExists(filePath))
            {
                // Remove media storage if any
                _fileSystem.DeleteFile(filePath);
            }
        }
Пример #4
0
        public void Put(CachedImageResult cachedImage, byte[] buffer)
        {
            if (PreparePut(cachedImage, buffer))
            {
                var path = BuildPath(cachedImage.Path);

                _fileSystem.WriteAllBytes(path, buffer);

                cachedImage.Exists = true;
                cachedImage.File   = _fileSystem.GetFile(path);
            }
        }
Пример #5
0
        public void Put(CachedImageResult cachedImage, byte[] buffer)
        {
            if (PreparePut(cachedImage, buffer))
            {
                var path = BuildPath(cachedImage.Path);

                if (cachedImage.Extension == "svg")
                {
                    _fileSystem.WriteAllText(path, Encoding.UTF8.GetString(buffer));
                }
                else
                {
                    _fileSystem.WriteAllBytes(path, buffer);
                }

                cachedImage.Exists = true;
                cachedImage.File   = _fileSystem.GetFile(path);
            }
        }