Hi,
We would like to read csv file from AWS s3 bucket instead of local drive. Could you please share sample code for that?
Thanks,
Varun
Hello, Varun!
Thank you for writing to us.
Flexmonster supports connecting CSV and JSON files from cloud storage, such as AWS S3.
Since S3 files often require authentication, we would like to mention that Flexmonster allows setting request headers with credentials using the requestHeders
data source object property.
For reference, you can check this example, which loads a CSV file from our CDN: https://jsfiddle.net/flexmonster/u5Lp4k98/
Please let us know if our answer helped you.
Best Regards,
Maksym
Hi Maksym,
Thanks for your reply! Does this mean Flexmonster already have inbuilt library to connect AWS S3 bucket and we just need to pass file path like to read csv s3://aligne-rds-sim-refresh-bucket/REFRESH_SIM_01.csv ?
In our case we mainly use AWS_ACCESS_KEY_ID,AWS_SECRET_ACCESS_KEY and AWS region for authentication.
Thanks,
Varun
Just to be sure we are using FDS to read csv file
Hello, Varun!
Thank you for providing additional context.
Flexmonster Data Server does not support connecting to S3 files. However, there are several potential solutions for working with CSV files on S3:
Please let us know if one of these approaches would work for you. Also, we would like to know if you are asking about working with CSV files on S3 because it would just be convenient to have, or because it is critically important for your task?
Looking forward to hearing from you.
Best Regards,
Maksym
Hi,
Example you have shown is creating custom index initially i.e. in builder while we are creating index dynamically by using below method
public async Task<IActionResult> PostFields([FromBody]FieldsRequest request)
{
await _createService.CreateIndexIfNotExists(request.Index);
var response = await _apiService.GetFieldsAsync(request);
return new JsonResult(response);
}
Since we are storing data into S3 bucket and would like to create a custom dynamic index where we will retrieve csv data in memory stream and then populate it into Pivot Grid.
Can it be done? If yes, could you please share .net example for the same?
Thanks,
Varun
Hello, Varun!
Thank you for your reply.
We are working on an example that demonstrates dynamically creating a custom index by loading a CSV file from a URL. We will get back to you once it is ready.
Best Regards,
Maksym
Hello, Varun!
We have modified the sample .NET project with Flexmonster DLL to include the custom parser, which reads remote CSV files from a URL. The project is available on our GitHub: https://github.com/flexmonster/flexmonster-data-server-dll/tree/csv-url-parser-runtime-index-creation
You can find a quick breakdown of what was added or changed below:
CSVURLParser
parser implementation, based on the existing CSVParser
. Its type is set to "csv_url"
to make it distinguishable from other index types, and the Parse()
method has been updated to fetch CSV content over HTTPS using HttpClient
(see line 72). The implementation can be further adapted for S3 or other sources.CsvIndexOptions
. Our implementation only overrides the type; however, you can add further changes to pass more settings, such as AWS credentials.CsvUrlIndexOptions
.Please let us know if the provided sample helped you.
Best Regards,
Maksym
Thanks, Maksym! It works.
Is there a way to find list of all indexes when running FDS as dll and delete them via post command on demand?
Hello, Varun!
Thank you for your question.
These can be implemented within the dedicated service for managing indexes, or by adding methods to the existing IndexCreateService
:
using Flexmonster.DataServer.Core.DataStorages;
using Flexmonster.DataServer.Core;
using System.Threading.Tasks;
using Microsoft.Extensions.Options;
using Flexmonster.DataServer.Core.Parsers;
using System.Collections.Generic;
namespace DemoDataServerCore.Controllers
{
public class IndexManagementService
{
private readonly IDataStorage _dataStorage;
private readonly DatasourceOptions _datasourceOptions;
public IndexManagementService(IDataStorage dataStorage, IOptionsMonitor<DatasourceOptions> datasourceOptions)
{
_dataStorage = dataStorage;
_datasourceOptions = datasourceOptions.CurrentValue;
}
public Dictionary<string, IndexOptions> GetAllIndexes()
{
return _datasourceOptions.Indexes;
}
public void DeleteIndex(string indexName)
{
if (_datasourceOptions.Indexes.ContainsKey(indexName))
{
_datasourceOptions.Indexes.Remove(indexName);
_dataStorage.Remove(indexName);
}
}
}
}
Note that the service must be registered within the Startup.cs
:
services.AddScoped<IndexManagementService>();
These service methods provide a clean abstraction, and you can implement and configure controller endpoints using them.
Please let us know if our answer helped you.
Best Regards,
Maskym