diff --git a/Interfaces/IXFileProvider.cs b/Interfaces/IXFileProvider.cs
index 601f376..1e04a78 100644
--- a/Interfaces/IXFileProvider.cs
+++ b/Interfaces/IXFileProvider.cs
@@ -76,6 +76,21 @@ namespace xFileService.Interfaces
CancellationToken cancellationToken = default
);
+ ///
+ /// Upload File ...
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ Task Upload(
+ IFormFile file,
+ XUserClaimsInfoDto userInfo = null,
+ string connectionId = null,
+ CancellationToken cancellationToken = default
+ );
+
///
/// Remove Specified Files ...
///
diff --git a/Providers/XFileProvider.cs b/Providers/XFileProvider.cs
index eae50b0..071972a 100644
--- a/Providers/XFileProvider.cs
+++ b/Providers/XFileProvider.cs
@@ -335,6 +335,73 @@ namespace xFileService.Providers
return result;
}
+ ///
+ /// Upload File ...
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ public virtual async Task Upload(
+ IFormFile file,
+ XUserClaimsInfoDto userInfo = null,
+ string connectionId = null,
+ CancellationToken cancellationToken = default
+ )
+ {
+ //
+ // Validate Args ...
+ var isValid = !file.IsNull() &&
+ !userInfo.IsNullOrDefault();
+ if (!isValid)
+ {
+ XException.InvalidArgs.Throw();
+ }
+
+ //
+ // Save Files On Server Side Physically ...
+ // and Validate it ...
+ var uploadResult = await storageProvider
+ .HandleFileSave(file, cancellationToken);
+ isValid = !uploadResult.IsNullOrDefault();
+ if (!isValid)
+ {
+ XException.ActionFailed.Throw();
+ }
+
+ //
+ // Prepare Result ...
+ //
+ var fileType = storageProvider.GetFileType(uploadResult.FileName);
+
+ //
+ // Create Item Model ...
+ var item = new XFileDto
+ {
+ Type = fileType,
+ OwnerId = userInfo.UserId,
+ FileName = uploadResult.Name,
+ Name = uploadResult.FileName,
+ Path = uploadResult.FilePath,
+ Thumb = uploadResult.Thmbnail,
+ UploadedOn = DateTime.UtcNow,
+ ThumbPath = uploadResult.ThmbnailPath,
+ };
+
+ //
+ // Add Entity Model to DB ...
+ var result = await Add(
+ item: item,
+ userInfo: userInfo,
+ connectionId: connectionId,
+ cancellationToken: cancellationToken
+ );
+
+ //
+ return result;
+ }
+
///
/// Remove Specified Files ...
///