dd2f00cd37
- Replace Slint UI with HTTP server using actix-web - Add CORS support for prism.ccllc.pro - Implement /open endpoint to open NAS folders in file explorer - Add /health endpoint for server status - Support Windows, macOS, and Linux - Update README with usage instructions
2.9 KiB
2.9 KiB
RPC - NAS Folder Opener
A local HTTP server that opens NAS folder paths in the system file explorer. Designed to work with the PRISM web application hosted at prism.ccllc.pro.
Purpose
Browsers cannot directly open network file shares (NAS folders) due to security restrictions. This tool bridges that gap by:
- Running a local HTTP server on
localhost:8080 - Accepting requests from the PRISM web application
- Opening NAS folder paths in the user's file explorer
How It Works
- User visits PRISM at
prism.ccllc.proand views job information - User clicks a folder link from the
Job_Folder_Linkfield - PRISM makes a request to
http://localhost:8080/open?path=<NAS_PATH> - RPC tool opens the path in the system file explorer
Installation
Prerequisites
- Rust toolchain installed (rustup.rs)
Build
cargo build --release
The binary will be in target/release/rpc (or target/release/rpc.exe on Windows).
Run
cargo run
Or run the release binary:
./target/release/rpc
The server will start on http://127.0.0.1:8080.
API Endpoints
GET /open?path=<NAS_PATH>
Opens a NAS folder path in the file explorer.
Query Parameters:
path(required): The NAS folder path to open. Supports:- UNC paths:
\\server\share\folder - SMB paths:
smb://server/share/folder - Unix-style:
//server/share/folder
- UNC paths:
Response:
{
"success": true,
"message": "Opening path: \\\\server\\share\\folder"
}
Error Response:
{
"success": false,
"message": "Error description"
}
GET /health
Health check endpoint.
Response:
{
"status": "ok",
"service": "NAS Folder Opener",
"version": "0.1.0"
}
Security
- The server only accepts requests from
https://prism.ccllc.pro(CORS) - Paths are validated to ensure they are network shares
- Server only binds to
127.0.0.1(localhost), not exposed to network
Integration with PRISM
In your Svelte component, add a function to open NAS folders:
async function openNasFolder(nasPath: string) {
try {
const response = await fetch(
`http://localhost:8080/open?path=${encodeURIComponent(nasPath)}`
);
const result = await response.json();
if (!result.success) {
alert(`Failed to open folder: ${result.message}`);
}
} catch (error) {
alert('Please ensure the NAS opener tool is running on your computer');
console.error('Error opening NAS folder:', error);
}
}
Then use it when displaying job folder links:
<button onclick={() => openNasFolder(job.Job_Folder_Link)}>
Open Folder
</button>
Cross-Platform Support
- Windows: Uses
explorer.exe - macOS: Uses
opencommand - Linux: Uses
xdg-opencommand
License
Apache-2.0