Files
Store files for your project, optimize for separate screens and automatically bind files with the records from the database
Last updated
var projectId = Guid.Parse("{YOUR_PROJECT_ID}");
var apiKey = "{YOUR_SECRET_KEY}";
var client = new NorbixClient(apiKey, projectId);
var filesService = new NorbixFilesService(client);use Norbix\NorbixClient;
use Norbix\NorbixFile;
class NorbixService
{
protected NorbixFile $norbixFile;
public function __construct()
{
$secretKey = '{YOUR_SECRET_KEY}';
$projectId = '{YOUR_PROJECT_ID}';
$client = new NorbixClient($secretKey, $projectId);
$this->norbixFile = new NorbixFile($client);
}
}using System;
using Norbix.Client;
using Norbix.Membership.Services;
using Isidos.Norbix.ServiceContracts;
namespace ConsoleApplication
{
class Program
{
static void Main(string[] args)
{
// 1. Get your Project ID and Secret Key
var projectId = Guid.Parse("{YOUR_PROJECT_ID}");
var apiKey = "{YOUR_SECRET_KEY}";
// 2. Create a general client for API calls
var client = new NorbixClient(apiKey, projectId);
// 3. Create a service object
var filesService = new NorbixFilesService(client);
// 4. Get path to your file
var directory = Path.GetDirectoryName(
Assembly.GetExecutingAssembly().Location
);
var filePath = $"{directory}\\test.txt";
// 5. Get file stream
using (var fsSource = new FileStream(path, FileMode.Open,
FileAccess.Read))
{
// 6. Call an API method
var response = await filesService.UploadFileAsync(
fsSource,
"test.txt",
new UploadFileRequest
{
Path = "folder1"
}
);
}
}
}
}use Norbix\NorbixClient;
use Norbix\NorbixFile;
class NorbixService
{
protected NorbixFile $norbixFile;
public function __construct()
{
$secretKey = '{YOUR_SECRET_KEY}';
$projectId = '{YOUR_PROJECT_ID}';
$client = new NorbixClient($secretKey, $projectId);
$this->norbixFile = new NorbixFile($client);
}
public function uploadFile()
{
$responseData = $norbixFile->uploadRecordFile([
'fileUri' => '{YOUR_FILE_PATH}',
'fileName' => '{YOUR_FILE_NAME}',
'collectionName' => '{COLLECTION_NAME}',
'recordId' => '{RECORD_ID}',
'uniqueFieldName' => 'file_field_name',
]);
}
}