Пример #1
0
        public override FileServerResult StoreImage(System.Drawing.Image objImage, IFileQuery qryFileDestination, System.Drawing.Imaging.ImageFormat enuFormat = null)
        {
            if (CDNOnly)
            {
                var result = new FileServerResult(true);
                var blob   = GetBlobForStorage(qryFileDestination);
                using (System.IO.MemoryStream stmImage = new System.IO.MemoryStream())
                {
                    if (enuFormat != null)
                    {
                        objImage.Save(stmImage, enuFormat);
                    }
                    else
                    {
                        objImage.Save(stmImage, objImage.RawFormat);
                    }

                    stmImage.Seek(0, SeekOrigin.Begin);
                    blob.UploadFromStream(stmImage);
                }
                result.Uri = blob.Uri;
                return(result);
            }
            else
            {
                var result = base.WriteImageLocal(objImage, qryFileDestination, enuFormat);
                if (result.Success)
                {
                    var blob = GetBlobForStorage(qryFileDestination);
                    blob.UploadFromFile(GetLocalDiskPath(qryFileDestination));
                    result.Uri = blob.Uri;
                }
                return(result);
            }
        }
Пример #2
0
 public FileServerResult DeleteFileLocal(IFileQuery qryFile)
 {
     if (FileExistsLocal(qryFile))
     {
         System.IO.File.Delete(GetLocalDiskPath(qryFile));
     }
     return(FileServerResult.Successful());
 }
Пример #3
0
 public FileServerResult WriteImageLocal(string strSourceImagePath, IFileQuery qryFile)
 {
     if (Settings.LocalReadOnlyMode)
     {
         return(FileServerResult.Failure());
     }
     System.IO.File.Copy(strSourceImagePath, GetAndCreateLocalDiskPath(qryFile), Settings.OverwriteExistingFiles);
     return(FileServerResult.Successful());
 }
Пример #4
0
        public override FileServerResult StoreImage(string strSourceImagePath, IFileQuery qryFileDestination)
        {
            var result = new FileServerResult(false);
            var blob   = GetBlobForStorage(qryFileDestination);

            blob.UploadFromFile(strSourceImagePath);
            result = base.WriteImageLocal(strSourceImagePath, qryFileDestination);
            return(result);
        }
Пример #5
0
        public override FileServerResult StoreFileFromString(string strFileBody, IFileQuery qryFileDestination, Encoding encoding = null)
        {
            var result = new FileServerResult(false);
            var blob   = GetBlobForStorage(qryFileDestination);

            blob.UploadText(strFileBody, encoding);
            result = base.WriteFileFromStringLocal(strFileBody, qryFileDestination, encoding);
            return(result);
        }
Пример #6
0
        public override FileServerResult StoreImage(string strSourceImagePath, IFileQuery qryFileDestination)
        {
            var result = new FileServerResult(false);
            var fileTransferUtilityRequest = GetUploadRequest(qryFileDestination);

            fileTransferUtilityRequest.FilePath = strSourceImagePath;
            S3TransferUtil.Upload(fileTransferUtilityRequest);
            result = base.WriteImageLocal(strSourceImagePath, qryFileDestination);
            return(result);
        }
Пример #7
0
        public override FileServerResult StoreFile(string strSourceFilePath, IFileQuery qryFileDestination)
        {
            var result = new FileServerResult(true);
            var blob   = GetBlobForStorage(qryFileDestination);

            blob.UploadFromFile(strSourceFilePath);
            if (!CDNOnly)
            {
                result = base.WriteFileLocal(strSourceFilePath, qryFileDestination);
            }
            result.Uri = blob.Uri;
            return(result);
        }
Пример #8
0
 public FileServerResult WriteFileFromStringLocal(string strFileBody, IFileQuery qryFile, System.Text.Encoding encoding = null)
 {
     if (Settings.LocalReadOnlyMode)
     {
         return(FileServerResult.Failure());
     }
     if (encoding != null)
     {
         System.IO.File.WriteAllText(GetAndCreateLocalDiskPath(qryFile), strFileBody, encoding);
     }
     else
     {
         System.IO.File.WriteAllText(GetAndCreateLocalDiskPath(qryFile), strFileBody);
     }
     return(FileServerResult.Successful());
 }
Пример #9
0
 public FileServerResult WriteFileLocal(System.IO.Stream stmFile, IFileQuery qryFile)
 {
     if (Settings.LocalReadOnlyMode)
     {
         return(FileServerResult.Failure());
     }
     if (Settings.OverwriteExistingFiles)
     {
         DeleteFileLocal(qryFile);
     }
     using (var writer = new System.IO.StreamWriter(GetAndCreateLocalDiskPath(qryFile)))
     {
         stmFile.Seek(0, System.IO.SeekOrigin.Begin);
         stmFile.CopyTo(writer.BaseStream);
         writer.Close();
     }
     return(FileServerResult.Successful());
 }
Пример #10
0
 public FileServerResult WriteImageLocal(Image objImage, IFileQuery qryFile, System.Drawing.Imaging.ImageFormat enuFormat = null)
 {
     if (Settings.LocalReadOnlyMode)
     {
         return(FileServerResult.Failure());
     }
     if (Settings.OverwriteExistingFiles)
     {
         DeleteFileLocal(qryFile);
     }
     if (enuFormat != null)
     {
         objImage.Save(GetAndCreateLocalDiskPath(qryFile), enuFormat);
     }
     else
     {
         objImage.Save(GetAndCreateLocalDiskPath(qryFile));
     }
     return(FileServerResult.Successful());
 }
Пример #11
0
 public override FileServerResult StoreFile(System.IO.Stream stmFile, IFileQuery qryFileDestination)
 {
     if (CDNOnly)
     {
         var result = new FileServerResult(true);
         var blob   = GetBlobForStorage(qryFileDestination);
         blob.UploadFromStream(stmFile);
         result.Uri = blob.Uri;
         return(result);
     }
     else
     {
         var result = base.WriteFileLocal(stmFile, qryFileDestination);
         if (result.Success)
         {
             var blob = GetBlobForStorage(qryFileDestination);
             blob.UploadFromFile(GetLocalDiskPath(qryFileDestination));
         }
         return(result);
     }
 }
Пример #12
0
        public override FileServerResult Delete(IFileQuery qryFile)
        {
            FileServerResult result;

            if (CDNOnly)
            {
                result = new FileServerResult(true);
            }
            else
            {
                result = base.DeleteFileLocal(qryFile);
            }
            var blob      = GetBlob(qryFile);
            var blnResult = blob.DeleteIfExists();

            if (!blnResult)
            {
                result.Success = false;
                result.Message = "Blob delete failed at Azure";
            }
            return(result);
        }
Пример #13
0
 public override FileServerResult StoreImage(string strSourceImagePath, IFileQuery qryFileDestination)
 {
     var result = new FileServerResult(false);
     var fileTransferUtilityRequest = GetUploadRequest(qryFileDestination);
     fileTransferUtilityRequest.FilePath = strSourceImagePath;
     S3TransferUtil.Upload(fileTransferUtilityRequest);
     result = base.WriteImageLocal(strSourceImagePath, qryFileDestination);
     return result;
 }