Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/nicogis/azurefilestorexaf

Store FileData XAF (Web) in azure file
https://github.com/nicogis/azurefilestorexaf

azure-file-share devexpress filedata webforms xaf

Last synced: 9 days ago
JSON representation

Store FileData XAF (Web) in azure file

Awesome Lists containing this project

README

        

# How to: Store file attachments in the azure file instead of the database (XPO)

- Add in agnostic module AzureFileDataModule

```csharp
///
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
///
private void InitializeComponent() {
//
// AzureFileStoreXAFModule
//
this.AdditionalExportedTypes.Add(typeof(DevExpress.Persistent.BaseImpl.BaseObject));
this.AdditionalExportedTypes.Add(typeof(DevExpress.Persistent.BaseImpl.FileData));
this.AdditionalExportedTypes.Add(typeof(DevExpress.Persistent.BaseImpl.FileAttachmentBase));
this.RequiredModuleTypes.Add(typeof(DevExpress.ExpressApp.SystemModule.SystemModule));
this.RequiredModuleTypes.Add(typeof(DevExpress.ExpressApp.Objects.BusinessClassLibraryCustomizationModule));
this.RequiredModuleTypes.Add(typeof(AzureFileData.AzureFileDataModule));

}
```

- Create a property in your BO

```csharp
[DefaultClassOptions]
[FileAttachment("File")]
public class FileSystemStoreObjectDemo : BaseObject
{
public FileSystemStoreObjectDemo(Session session) : base(session) { }
[Aggregated, ExpandObjectMembers(ExpandObjectMembers.Never), ImmediatePostData]
public AzureFileStoreObject File
{
get { return GetPropertyValue("File"); }
set { SetPropertyValue("File", value); }
}
}
```

- Set in web.config the name of share folder in azure and [connectionstring azure](https://docs.microsoft.com/it-it/azure/storage/files/storage-how-to-create-file-share?tabs=azure-portal)

![Azurefile](AzureFileStoreXAF.Module/Images/AzureFile.png)

```xml

```

- Set parameter in start code (event login ect)
```csharp
AzureFileData.AzureFileDataModule.AzureFileConnectionString = ConfigurationManager.AppSettings["ConnectionString"];
AzureFileData.AzureFileDataModule.AzureFileShareLocation = ConfigurationManager.AppSettings["ShareName"];
```

You can upload file > 4Mb but you must set in web.config
```xml




.....

...






```

![Azurefilefiledataxaf](AzureFileStoreXAF.Module/Images/AzureFileFiledataXAF.PNG)

**Developed using only XAF (web) .NET Framework.**

**Extra info**

You can also use SMB Azure file share so you can use this project [XAF How to store file attachments in the file system instead of the database](https://github.com/DevExpress-Examples/XAF_how-to-store-file-attachments-in-the-file-system-instead-of-the-database-xpo-e965)

Azure Files offers fully managed file shares in the cloud that are accessible via the industry standard Server Message Block (SMB) protocol.
- Sign in to the Azure portal.
- Navigate to the storage account that contains the file share you'd like to mount.
- Select File shares.
- Select the file share you'd like to mount.
- Select Connect.
- Select the drive letter to mount the share to.
- Copy the provided script.