0

The goal of what i am trying to do is to take a photo and upload it using dropzone (which drop zone is working fine for how i have implemented it) and load it to an NTFS file system. I store the "uploadpath" to my SQL server so i can pull the image faster later. The problem that i am running into is i have no idea how to load my images into Azure File System. Also from what i gather a blob storage isnt quite what i am needing to use since that is based off a type of table storage format which isnt using ntfs.

I have been trying to research this and i have no idea where to actually start... i have read a few articles within MSDN to try to understand it but it seems that everything i keep finding is rather pertaining to BLOB storage.

                foreach (string filename in Request.Files)
            {
                HttpPostedFileBase file = Request.Files[filename];
                fname = file.FileName;
                if (file != null && file.ContentLength > 0)
                {

                    var path = Path.Combine(Server.MapPath("~/uploadeimg"));
                    string pathstring = Path.Combine(path.ToString()); 
                    string filename1 = Guid.NewGuid() + Path.GetExtension(file.FileName);
                    bool isexist = Directory.Exists(pathstring);
                    if (!isexist)
                    {
                        Directory.CreateDirectory(pathstring);
                    }
                    uploadpath = string.Format("{0}\\{1}", pathstring, filename1);
                    file.SaveAs(uploadpath);

As for documentation the following links are what i have read and looked through.

File Uploading to Azure Storage by ASP.NET Webpages https://learn.microsoft.com/en-us/azure/storage/files/storage-dotnet-how-to-use-files

https://learn.microsoft.com/en-us/azure/storage/files/storage-dotnet-how-to-use-files

https://learn.microsoft.com/en-us/azure/storage/blobs/storage-dotnet-how-to-use-blobs

I appreciate any assistance that you guys may be able to provide. I am looking to get more experience with this type of programming and i have just decided to play around and see what i can do with it.

I should also note. I can save the files in the area that i host the project and I can retrieve them that way as well. But i am not certain that would be the proper way to go about handling this.

Mitaku
  • 43
  • 2
  • 9
  • 1
    _"that is based off a type of table storage format which isnt using ntfs"_ - what's the relevance of NTFS here? – stuartd Jan 15 '18 at 16:21
  • The relevance is because from what research i have done they said that its faster to just store the file location in the sql database and just pass that location back when you want to view the image This is where i got this from https://stackoverflow.com/questions/3748/storing-images-in-db-yea-or-nay – Mitaku Jan 15 '18 at 16:23

2 Answers2

0

On Azure it is common to store your files in BLOB. I would recommend to store your photo on BLOB instead of storing them into the Azure Web App.

All objects saved into Azure BLOB have their own URL that you can store on your SQL database to retrieve them later.

Check https://learn.microsoft.com/en-us/azure/storage/common/storage-decide-blobs-files-disks?toc=%2fazure%2fstorage%2ffiles%2ftoc.json#comparison-files-and-blobs to get a clear comparison between Azure Files and BLOBS.

Sacha Bruttin
  • 4,083
  • 2
  • 21
  • 17
  • I did not know they all got their own url :O that is quite useful! – Mitaku Jan 15 '18 at 16:33
  • This solved my issue and it’s pretty quick too! Thanks didn’t know about that url thing at all but yea this helped me a lot! – Mitaku Jan 17 '18 at 20:57
0

For the legacy applications which use the native file system APIs, you could mount your Azure File share in Azure VM or on-premises as the network drive, then access your file share just as the local file system. You could leverage AzCopy and Azure Storage Explorer to manage your file storage.

For Azure Web Apps, you could not mount the Azure File share. By default, Azure web app content is stored on Azure Storage which is managed by azure side. You could just leverage the Home directory access (d:\home) and store your files on Azure Web. Details you could follow Azure Web App sandbox about the File System Restrictions/Considerations section.

In summary, we recommend you store your files into Azure Blob storage. And you could use azure storage client library to communicate with your blob storage, details you could follow here.

Bruce Chen
  • 18,207
  • 2
  • 21
  • 35