Example #1
0
        public override FileUploadResult SaveFile(string fileName, Stream fileContent)
        {
            FileUploadResult result = new FileUploadResult()
            {
                Code = -1
            };

            if (fileContent != null)
            {
                CloudFile file = fileDirectory.GetFileReference(fileName);


                byte[] array;
                using (var ms = new MemoryStream())
                {
                    fileContent.CopyTo(ms);
                    array = ms.ToArray();
                }

                file.Create(array.Length);

                file.UploadFromByteArray(array, 0, array.Length);

                result.Code = 0;
            }

            return(result);
        }
Example #2
0
        public override FileUploadResult SaveFile(string fileName, Stream fileContent)
        {
            FileUploadResult result = new FileUploadResult()
            {
                Code = -1
            };

            if (fileContent != null)
            {
                using (Stream outputStream = File.OpenWrite(FinalDestinationFolder + Path.DirectorySeparatorChar + fileName))
                {
                    byte[] buffer = new byte[4096];
                    int    bytesRead;
                    do
                    {
                        bytesRead = fileContent.Read(buffer, 0, buffer.Length);
                        outputStream.Write(buffer, 0, bytesRead);
                    } while (bytesRead != 0);
                }

                result.Code = 0;
            }

            return(result);
        }
        public FileUploadResult SaveFileFromURL(string sourceURL, string fileName)
        {
            Stream downloadedFile = Utils.DownloadRemoteImageFile(sourceURL);

            FileUploadResult result = SaveFile(fileName, downloadedFile);

            return(result);
        }
Example #4
0
        public override FileUploadResult SaveFile(string fileName, Stream fileContent)
        {
            FileUploadResult result = new FileUploadResult()
            {
                Code = -1
            };

            if (fileContent != null)
            {
                CloudBlockBlob blockBlob = blobContainer.GetBlockBlobReference(fileName);
                blockBlob.UploadFromStream(fileContent);

                result.Code = 0;
            }

            return(result);
        }