Add SapFileController and route for reading SAP files

This commit is contained in:
dhanabalan
2025-09-23 09:34:17 +05:30
parent 7ca806449c
commit 7e1852cfed
2 changed files with 92 additions and 0 deletions

View File

@@ -0,0 +1,88 @@
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
class SapFileController extends Controller
{
/**
* Display a listing of the resource.
*/
public function index()
{
//
}
/**
* Store a newly created resource in storage.
*/
// public function store(Request $request)
// {
// //
// }
public function getSapData(Request $request)
{
}
public function readFiles()
{
$path = "/srv/pds.iotsignin.com/sapftp/In/";
$files = scandir($path);
$data = [];
foreach ($files as $file) {
if ($file == '.' || $file == '..') continue; // skip system entries
if (is_file($path . $file) && pathinfo($file, PATHINFO_EXTENSION) == 'txt') {
$data[] = [
'filename' => $file,
'content' => file_get_contents($path . $file),
];
}
}
if (empty($data)) {
return response()->json([
'status' => 'error',
'message' => 'No text files found',
], 404);
}
return response()->json([
'status' => 'success',
'files' => $data,
]);
}
/**
* Display the specified resource.
*/
public function show(string $id)
{
//
}
/**
* Update the specified resource in storage.
*/
public function update(Request $request, string $id)
{
//
}
/**
* Remove the specified resource from storage.
*/
public function destroy(string $id)
{
//
}
}