public async Task<string> SaveDocumentAndGetName(IFormCollection data, string folderPath, string fileNameWhichIsDirectoryID)
{
if (data.Files.Count == 0)
return "";
BlobServiceClient blobServiceClient = new BlobServiceClient(_storageConnectionString);
BlobContainerClient MasterContainerName = blobServiceClient.GetBlobContainerClient(_storageMasterContainerName);
BlobContainerClient UserContainerName = blobServiceClient.GetBlobContainerClient(_storageUserContainerName);
IFormFile file = data.Files[0];
string documentName = this.GetValue(data, "documentName");
string documentNameWithoutExtension = Path.GetFileNameWithoutExtension(documentName);
string extension = Path.GetExtension(documentName);
BlobClient blobClient;
// Get a reference to the blob
// if (role == "docadmin")
// {
blobClient = MasterContainerName.GetBlobClient(folderPath + fileNameWhichIsDirectoryID + ".sfdt");
// }
// else
// {
// blobClient = UserContainerName.GetBlobClient(folderPathForUser + fileNameWhichIsDirectoryID + ".sfdt");
// }
Stream stream = new MemoryStream();
file.CopyTo(stream);
// Ensure the stream position is set to the beginning
stream.Position = 0;
// Upload the document to Azure Blob Storage
blobClient.Upload(stream, true);
// Return the URL of the uploaded blob
return documentNameWithoutExtension + extension;
}
2. Open
Angular
this.documentSyncfusionService
.getDocumentByID(formData)
.then((apiResult: any) => {
// if (apiResult.Success) {
// this.toaster.success('Docment Fetched Sucessfully...!')
if (apiResult?.Document) {
this.documentInfo = JSON.parse(apiResult?.Document);
}
const documentContentString = JSON.stringify(
this.documentInfo.DocumentContent
);
this.editorObj.documentEditor?.open(documentContentString);
.Net
public async Task<string> SaveDocumentAndGetName(IFormCollection data, string folderPath, string fileNameWhichIsDirectoryID)
{
if (data.Files.Count == 0)
return "";
BlobServiceClient blobServiceClient = new BlobServiceClient(_storageConnectionString);
BlobContainerClient MasterContainerName = blobServiceClient.GetBlobContainerClient(_storageMasterContainerName);
BlobContainerClient UserContainerName = blobServiceClient.GetBlobContainerClient(_storageUserContainerName);
IFormFile file = data.Files[0];
string documentName = this.GetValue(data, "documentName");
string documentNameWithoutExtension = Path.GetFileNameWithoutExtension(documentName);
string extension = Path.GetExtension(documentName);
BlobClient blobClient;
// Get a reference to the blob
// if (role == "docadmin")
// {
blobClient = MasterContainerName.GetBlobClient(folderPath + fileNameWhichIsDirectoryID + ".sfdt");
// }
// else
// {
// blobClient = UserContainerName.GetBlobClient(folderPathForUser + fileNameWhichIsDirectoryID + ".sfdt");
// }
Stream stream = new MemoryStream();
file.CopyTo(stream);
// Ensure the stream position is set to the beginning
stream.Position = 0;
// Upload the document to Azure Blob Storage
blobClient.Upload(stream, true);
// Return the URL of the uploaded blob
return documentNameWithoutExtension + extension;
}
and from controller i have retuned like this ,
string Document = await _documentBussiness.GetDocumentJsonFromFileName(docTitle, folderPath, DirectoryIDString);
var ResultData = new
{
Document = Document,
result = result
};