Scenario
The FileSystemData module provides the FileSystemStoreObject and FileSystemLinkObject classes that implement the IFileData interface for the use with our File Attachments module.
FileSystemStoreObject - this class enables you to store uploaded files in a centralized file system location instead of the database. You can configure the file system store location via the static FileSystemDataModule.FileSystemStoreLocation property.
FileSystemLinkObject - this class enables you to add soft links to real files instead of saving their contents to the database. Apparently, it is intended for use in Windows Forms applications only.
Refer to the following video to see this functionality in action: http://www.screencast.com/t/Xl1GMfxw
Steps to implement
1. Copy and include the FileSystemData project into your solution and make sure it is built successfully.
2. Invoke the Module Designer for the YourSolutionName.Module/Module.xx file by double-clicking it in Solution Explorer. Invoke the Toolbox (Alt+X+T) and then drag & drop the FileSystemDataModule component into the modules list on the left.
3. Define a FileSystemStoreObject or FileSystemLinkObject type properties within your business class as described in the eXpressApp Framework > Task-Based Help > How to: Implement File Data Properties article. Make sure to decorate the container business class with the FileAttachmentAttribute to provide additional commands for working with files. See the E965.Module\BusinessObjects\FileSystemStoreObjectDemo.xx and E965.Module\BusinessObjects\FileSystemLinkObjectDemo.xx source files for examples.
4. Make sure you do not override the DevExpress.Persistent.BaseImpl.BaseObject.OidInitializationMode property in your application and related modules, because the OidInitializationMode.AfterConstruction value is necessary for the correct operation of this module (in the example, the required default value is already set in the FileSystemDataModule class of this example module).
5. Modify YourSolutionName.Win/WinApplication.xx file to handle the CustomOpenFileWithDefaultProgram event of the DevExpress.ExpressApp.FileAttachments.Win.FileAttachmentsWindowsFormsModule class as shown in the E965.Win\WinApplication.xx file.
IMPORTANT NOTES
1. The current version of this example does not support the middle-tier scenario. Refer to the Q476039 ticket for more details.
See Also:
File Attachments Module Overview
Working with links to files instead of storing their contents in the database
SQL Server FILESTREAM feature Overview
Question Comments
Added By: Roger Gardner at: 8/2/2012 4:36:37 AM
-How to change FileStoreObject to work With Application server?
-How many files you can store in one folder and the system is not to slow?
Can this sample be upgraded with Application server and multiple folders in File Data Store folder?
Added By: Sander Mclean at: 8/22/2012 12:31:10 AMThank you for your example, but could you upgrade this to VB.NET?
Added By: Martin Kraeuchi at: 10/12/2012 2:00:24 AMI tried to run this example but it crashes.
It occurs a fatal error when I try to append a file after creating a new "Standard File Data Demo" Item. The error occurs at the moment the file select box opens. I didn't found a way to debug it.
Do you have a glue what it could be?
My configuration:
Win7 64BIT, VS2010, v2012 vol 1.7, SQL Server Express 2008 R2
Thanks, Martin
Added By: Dennis (DevExpress Support) at: 11/29/2012 9:56:43 AM@Roger: I have not yet tested this module with the application server. It is a good idea, though. Thank you for your input, I have added it to my TODO list.
@Sander: It is quite complex a module to rewrite it in VB.NET, as well as maintain two versions later. Even though it is not in my immediate plans, you can either include the C# module project into your VB.NET solution (Visual Studio allows this) or rather use free or paid conversion tools.
@Martin: Thank you for your comment. Hm, it performs perfectly well for me. I also ran functional tests that passed locally. You are probably not using the latest version in this example. It would be great if you could create a separate ticket in the Support Center and attach the eXpressAppFramework.log file with the error details. Thank you in advance!
PS.
Sorry for the late reply, guys. In the future, it is better to submit a ticket directly via the http://www.devexpress.com/Support/Center/Question/Create link, if you experienced any difficulties with our tools.
Hi,
I'm working with Images in XAF application storing user image file to file system. So I'm using FileSystemStoreObject and It work fine for me. However, I've some problem!
one - I'd like split and save user images in FileData\<mykey1> folder where mykey1 depends by Business Objects instance1,
user images in FileData\<mykey2> folder where mykey2 depends by Business Objects instance2 and so on.
two - I'd like show stored images like Asp.net Images Slides Control or a link item in grid view to open images.
Do you have any suggestion or example?
Best regards,
Gaetano
Do vou have an exemple of this as a domain componente?
Regards,
Ricardo
Did the "StandardFileDataDemo" store file attachments in database?
Added By: Dennis (DevExpress Support) at: 6/3/2014 2:24:48 AM@xaero: The StandardFileDataDemo class uses the FileData class that stores files in the database and which is a part of the standard delivery.
In turn, the FileSystemStoreObjectDemo class stores files in the file system with the help of custom IFileData implementations described in this example.
Added By: Steve Perks @ NSS at: 9/19/2014 4:11:17 AMHi Dennis, thank you for the code - it works great in my web application (I'm only using the FileSystemStoreObject). I've made a mod to cover the case where the user has previously saved a business object and subsequently reloads it to edit the FileSystemStoreObject property, namely to pick a different file. In this case _tempFileName is not correctly populated and the old file is not deleted when the file is changed and the business object saved.
My solution was to add the following code to FileSystemStoreObject.cs
protected override void OnLoaded()
{
base.OnLoaded();
_tempFileName = this.RealFileName;
}
Hope this helps others and perhaps you could update your code if you also feel this is a good solution.
Added By: Dennis (DevExpress Support) at: 9/19/2014 5:21:49 AMThanks for sharing, Steve. Would you please either record a video showing how to replicate this behavior with the original example or create a functional EasyTest script covering this scenario? This will help me better understand the situation and make changes, if necessary. Thanks in advance!
Added By: Steve Perks @ NSS at: 9/19/2014 5:47:52 AMDennis, how shall I send the video? No attachments in this thread.
Added By: Steve Perks @ NSS at: 9/19/2014 6:09:35 AMIt's ok about sending the video, I've decided to host it for a short while here: http://host21.co.uk/e965/
Added By: Dennis (DevExpress Support) at: 9/19/2014 6:13:09 AM Thanks for your video, Steve. I will take this scenario into account for future updates.Added By: Genesis Supsup 1 at: 12/30/2015 2:07:35 AMDoes this already work using Application Server? Given the correct credentials, will this concept work with Dropbox (in replacement to File System)?