Store files for your project, optimize for separate screens and automatically bind files with the records from the database
CodeMash Files service allows you to store all your project files. These files include files from the database, user files, and custom files. All the files can be seen from the dashboard in the file browser.
To start using Files services and API methods you firstly need to enable files service in your CodeMash dashboard.
Features included in files service:
File storage - storing your project files.
Using SDK
If you decide to use one of our provided SDK, the following code shows how to initialize files service.
var projectId =Guid.Parse("{YOUR_PROJECT_ID}");var apiKey ="{YOUR_SECRET_KEY}";var client =newCodeMashClient(apiKey, projectId);var filesService =newCodeMashFilesService(client);
The following are examples of files SDK using different languages and frameworks.
usingSystem;usingCodeMash.Client;usingCodeMash.Membership.Services;usingIsidos.CodeMash.ServiceContracts;namespaceConsoleApplication{classProgram {staticvoidMain(string[] args) { // 1. Get your Project ID and Secret Keyvar projectId =Guid.Parse("{YOUR_PROJECT_ID}");var apiKey ="{YOUR_SECRET_KEY}"; // 2. Create a general client for API callsvar client =newCodeMashClient(apiKey, projectId); // 3. Create a service objectvar filesService =newCodeMashFilesService(client); // 4. Get path to your filevar directory =Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location );var filePath =$"{directory}\\test.txt"; // 5. Get file streamusing (var fsSource =newFileStream(path,FileMode.Open,FileAccess.Read)) { // 6. Call an API methodvar response =awaitfilesService.UploadFileAsync( fsSource,"test.txt",newUploadFileRequest { Path ="folder1" } ); } } }}