Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
---
layout: post
title: Save document to AWS S3 in Document editor | Syncfusion
description: Learn about how to Save document to AWS S3 in ASP.NET Core Document editor of Syncfusion Essential JS 2 and more details.
title: Save document to AWS S3 in DOCX Editor | Syncfusion
description: Learn about how to Save document to AWS S3 in ASP.NET Core Document Editor of Syncfusion Essential JS 2 and more details.
platform: document-processing
control: Save document to AWS S3
documentation: ug
domainurl: ##DomainURL##
---

# Save document to AWS S3 in Document editor Component
# Save document to AWS S3 in Document Editor Component

To save a document to AWS S3, you can follow the steps below
To save a document to AWS S3, follow these steps:


**Step 1:** Create a Simple [ASP.NET Core DOCX Editor](https://www.syncfusion.com/docx-editor-sdk/asp-net-core-docx-editor) (Document Editor) Sample in ASP.NET Core

Start by following the steps provided in this [link](../../document-editor/getting-started-core) to create a simple Document Editor sample in ASP.NET Core. This will give you a basic setup of the Document Editor component.
Follow the steps in this [link](../../document-editor/getting-started-core) to create a simple Document Editor sample in ASP.NET Core. This will give you a basic setup of the Document Editor component.


**Step 2:** Modify the `DocumentEditorController.cs` File in the Web Service Project
Expand All @@ -25,15 +25,19 @@ Start by following the steps provided in this [link](../../document-editor/getti
* Import the required namespaces at the top of the file:

```csharp
using Microsoft.AspNetCore.Cors;
using Microsoft.AspNetCore.Http;
using System.IO;
using Amazon;
using Amazon.S3;
using Amazon.S3.Model;
```

* Add the following private fields and constructor parameters to the `DocumentEditorController` class, In the constructor, assign the values from the configuration to the corresponding fields
* Add the following private fields and a constructor to the `DocumentEditorController` class. In the constructor, assign the configuration values to the corresponding fields.

```csharp
private IWebHostEnvironment _hostingEnvironment;
private IMemoryCache _cache;
private IConfiguration _configuration;
public readonly string _accessKey;
public readonly string _secretKey;
Expand All @@ -50,15 +54,15 @@ public DocumentEditorController(IWebHostEnvironment hostingEnvironment, IMemoryC
}
```

* Create the `SaveToS3()` method to save the document to AWS S3 bucket
* Create the `SaveToS3()` method to save the document to the AWS S3 bucket

```csharp

[AcceptVerbs("Post")]
[HttpPost]
[EnableCors("AllowAllOrigins")]
[Route("SaveToS3")]
//Post action for save the document to AWS S3
//Post action for saving the document to AWS S3

public void SaveToS3(IFormCollection data)
{
Expand Down Expand Up @@ -97,7 +101,7 @@ private string GetValue(IFormCollection data, string key)
}
```

* Open the `appsettings.json` file in your web service project, Add the following lines below the existing `"AllowedHosts"` configuration
* Open the `appsettings.json` file in your web service project. Add the following lines below the existing `"AllowedHosts"` configuration

```json
{
Expand All @@ -114,11 +118,11 @@ private string GetValue(IFormCollection data, string key)
}
```

N> Replace **Your Access Key from AWS S3**, **Your Secret Key from AWS S3**, and **Your Bucket name from AWS S3** with your actual AWS access key, secret key and bucket name
N> Replace **Your Access Key from AWS S3**, **Your Secret Key from AWS S3**, and **Your Bucket name from AWS S3** with your actual AWS access key, secret key, and bucket name.

**Step 3:** Modify the Index.cshtml File in the Document Editor sample

In the client-side, to export the document into blob the document using `saveAsBlob` and sent to server-side for saving in AWS S3 Bucket.
On the client side, export the document to a blob using `saveAsBlob` and send it to the server for saving in the AWS S3 bucket.


{% tabs %}
Expand All @@ -131,4 +135,4 @@ In the client-side, to export the document into blob the document using `saveAsB
{% endtabs %}


N> The **AWSSDK.S3** NuGet package must be installed in your application to use the previous code example.
N> The **AWSSDK.S3** NuGet package must be installed in your application to use the code above.
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
---
layout: post
title: Save to Azure Blob in Document editor | Syncfusion
description: Learn about how to Save document to Azure Blob Storage in ASP.NET Core Document editor control of Syncfusion Essential JS 2 and more details.
title: Save to Azure Blob in DOCX Editor | Syncfusion
description: Learn about how to Save document to Azure Blob Storage in ASP.NET Core Document Editor component of Syncfusion Essential JS 2 and more details.
platform: document-processing
control: Save document to Azure Blob Storage
documentation: ug
domainurl: ##DomainURL##
---

# Save document to Azure Blob Storage in ASP.NET Core
# Save document to Azure Blob Storage in Document Editor Component

To save a document to Azure Blob Storage, you can follow the steps below
To save a document to Azure Blob Storage, follow these steps:


**Step 1:** Create a Simple [ASP.NET Core DOCX Editor](https://www.syncfusion.com/docx-editor-sdk/asp-net-core-docx-editor) (Document Editor) Sample in ASP.NET Core

Start by following the steps provided in this [link](../../document-editor/getting-started-core) to create a simple Document Editor sample in ASP.NET Core. This will give you a basic setup of the Document Editor component.
Follow the steps in this [link](../../document-editor/getting-started-core) to create a simple Document Editor sample in ASP.NET Core. This will give you a basic setup of the Document Editor component.


**Step 2:** Modify the `DocumentEditorController.cs` File in the Web Service Project
Expand All @@ -27,12 +27,14 @@ Start by following the steps provided in this [link](../../document-editor/getti
* Import the required namespaces at the top of the file:

```csharp
using Microsoft.AspNetCore.Cors;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Logging;
using System.IO;
using Azure.Storage.Blobs;
using Azure.Storage.Blobs.Specialized;
```

* Add the following private fields and constructor parameters to the `DocumentEditorController` class, In the constructor, assign the values from the configuration to the corresponding fields
* Add the following private fields and a constructor to the `DocumentEditorController` class. In the constructor, assign the configuration values to the corresponding fields.

```csharp
private readonly string _storageConnectionString;
Expand All @@ -47,7 +49,7 @@ public DocumentEditorController(IConfiguration configuration, ILogger<DocumentEd
}
```

* Create then 'SaveToAzure' method to save the downloaded documents to Azure Blob Storage container
* Create the `SaveToAzure()` method to save the document to the Azure Blob Storage container

```csharp

Expand All @@ -56,7 +58,7 @@ public DocumentEditorController(IConfiguration configuration, ILogger<DocumentEd
[Route("[controller]/SaveToAzure")]
//Post action for downloading the documents

public void Download(IFormCollection data)
public void SaveToAzure(IFormCollection data)
{
if (data.Files.Count == 0)
return;
Expand All @@ -66,34 +68,21 @@ public void Download(IFormCollection data)

IFormFile file = data.Files[0];
string documentName = this.GetValue(data, "documentName");
string result = Path.GetFileNameWithoutExtension(documentName);
// Derive the blob name from the original document name (without extension)
string documentNameWithoutExt = Path.GetFileNameWithoutExtension(documentName);

// Get a reference to the blob
BlobClient blobClient = containerClient.GetBlobClient(result + "_downloaded.docx");
BlobClient blobClient = containerClient.GetBlobClient(documentNameWithoutExt + "_downloaded.docx");

Stream stream = new MemoryStream();
file.CopyTo(stream);

// Upload the document to Azure Blob Storage
blobClient.Upload(stream, true);
}

private string GetValue(IFormCollection data, string key)
{
if (data.ContainsKey(key))
{
string[] values = data[key];
if (values.Length > 0)
{
return values[0];
}
}
return "";
}

```

* Open the `appsettings.json` file in your web service project, Add the following lines below the existing `"AllowedHosts"` configuration
* Open the `appsettings.json` file in your web service project. Add the following lines below the existing `"AllowedHosts"` configuration

```json
{
Expand All @@ -109,11 +98,11 @@ private string GetValue(IFormCollection data, string key)
}
```

N> Replace **Your Connection string from Azure** with the actual connection string for your Azure Blob Storage account and **Your container name in Azure** with the actual container name
N> Replace **Your Connection string from Azure** with the actual connection string for your Azure Blob Storage account, and **Your container name in Azure** with the actual container name.

**Step 3:** Modify the Index.cshtml File in the Document Editor sample

In the client-side, to export the document into blob the document using `saveAsBlob` and sent to server-side for saving in Azure Blob Storage container.
On the client side, export the document to a blob using `saveAsBlob` and send it to the server for saving in the Azure Blob Storage container.


{% tabs %}
Expand All @@ -126,4 +115,4 @@ In the client-side, to export the document into blob the document using `saveAsB
{% endtabs %}


N> The **Azure.Storage.Blobs** NuGet package must be installed in your application to use the previous code example.
N> The **Azure.Storage.Blobs** NuGet package must be installed in your application to use the code above.
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
---
layout: post
title: Save to Box cloud file Document editor | Syncfusion
description: Learn about how to Save document to Box cloud file storage in ASP.NET Core Document editor control of Syncfusion Essential JS 2 and more details.
title: Save to Box cloud file storage in DOCX Editor | Syncfusion
description: Learn about how to Save document to Box cloud file storage in ASP.NET Core Document Editor component of Syncfusion Essential JS 2 and more details.
platform: document-processing
control: Save document to Box cloud file storage
documentation: ug
domainurl: ##DomainURL##
---

# Save document to Box cloud file storage in ASP.NET Core
# Save document to Box cloud file storage in Document Editor Component

To save a document to Box cloud file storage, you can follow the steps below
To save a document to Box cloud file storage, follow these steps:

**Step 1:** Set up a Box developer account and create a Box application

To access Box storage programmatically, you'll need a developer account with Box. Go to the [Box Developer Console](https://developer.box.com/guides), sign in or create a new account, and then create a new Box application. This application will provide you with the necessary credentials Client ID and Client Secret to authenticate and access Box APIs. Before accessing files, you need to authenticate your application to access your Box account. Box API supports `OAuth 2.0 authentication` for this purpose.
To access Box storage programmatically, you'll need a developer account with Box. Go to the [Box Developer Console](https://developer.box.com/guides), sign in or create a new account, and then create a new Box application. This application will provide you with the necessary credentials Client ID and Client Secret to authenticate and access Box APIs. Before accessing files, you need to authenticate your application to access your Box account. Box API supports OAuth 2.0 authentication for this purpose.


**Step 2:** Create a Simple Document Editor Sample in ASP.NET Core

Start by following the steps provided in this [link](../../document-editor/getting-started-core) to create a simple Document Editor sample in ASP.NET Core. This will give you a basic setup of the Document Editor component.
Follow the steps in this [link](../../document-editor/getting-started-core) to create a simple Document Editor sample in ASP.NET Core. This will give you a basic setup of the Document Editor component.


**Step 3:** Modify the `DocumentEditorController.cs` File in the Web Service Project
Expand All @@ -29,15 +29,22 @@ Start by following the steps provided in this [link](../../document-editor/getti
* Import the required namespaces at the top of the file:

```csharp
using Microsoft.AspNetCore.Cors;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Caching.Memory;
using Microsoft.Extensions.Configuration;
using System.IO;
using Box.V2;
using Box.V2.Auth;
using Box.V2.Config;
using Box.V2.Models;
```

* Add the following private fields and constructor parameters to the `DocumentEditorController` class, In the constructor, assign the values from the configuration to the corresponding fields
* Add the following private fields and a constructor to the `DocumentEditorController` class. In the constructor, assign the configuration values to the corresponding fields.

```csharp
private IWebHostEnvironment _hostingEnvironment;
private IMemoryCache _cache;
private IConfiguration _configuration;
public readonly string _accessToken;
public readonly string _clientID;
Expand All @@ -56,14 +63,14 @@ public DocumentEditorController(IWebHostEnvironment hostingEnvironment, IMemoryC
}
```

* Create the `SaveToBoxCloud()` method to save the downloaded document to Box cloud file storage bucket
* Create the `SaveToBoxCloud()` method to save the document to the Box cloud file storage

```csharp
[AcceptVerbs("Post")]
[HttpPost]
[EnableCors("AllowAllOrigins")]
[Route("SaveToBoxCloud")]
//Post action for downloading the document
//Post action for saving the document to Box cloud file storage

public void SaveToBoxCloud(IFormCollection data)
{
Expand All @@ -87,6 +94,7 @@ public void SaveToBoxCloud(IFormCollection data)

Stream stream = new MemoryStream();
file.CopyTo(stream);
stream.Position = 0;

var boxFile = await client.FilesManager.UploadAsync(fileRequest, stream);
}
Expand All @@ -105,7 +113,7 @@ private string GetValue(IFormCollection data, string key)
}
```

* Open the `appsettings.json` file in your web service project, Add the following lines below the existing `"AllowedHosts"` configuration
* Open the `appsettings.json` file in your web service project. Add the following lines below the existing `"AllowedHosts"` configuration

```json
{
Expand All @@ -123,11 +131,11 @@ private string GetValue(IFormCollection data, string key)
}
```

N> replace **Your_Box_Storage_Access_Token** with your actual box access token, and **Your_Folder_ID** with the ID of the folder in your box storage where you want to perform specific operations. Remember to use your valid box API credentials, as **Your_Box_Storage_ClientID** and **Your_Box_Storage_ClientSecret"** are placeholders for your application's API key and secret.
N> Replace **Your_Box_Storage_Access_Token** with your actual Box access token, and **Your_Folder_ID** with the ID of the folder in your Box storage where you want to perform specific operations. Remember to use your valid Box API credentials, as **Your_Box_Storage_ClientID** and **Your_Box_Storage_ClientSecret** are placeholders for your application's API key and secret.

**Step 4:** Modify the Index.cshtml File in the Document Editor sample

In the client-side, to export the document into blob the document using `saveAsBlob` and sent to server-side for saving in Box cloud file storage.
On the client side, export the document to a blob using `saveAsBlob` and send it to the server for saving in Box cloud file storage.


{% tabs %}
Expand All @@ -140,4 +148,4 @@ In the client-side, to export the document into blob the document using `saveAsB
{% endtabs %}


N> The **Box.V2.Core** NuGet package must be installed in your application to use the previous code example.
N> The **Box.V2.Core** NuGet package must be installed in your web service project to use the code above.
Loading