Table of Contents

Class File

Namespace
ROCrates.Models
Assembly
ROCrates.Net.dll

This class represents a generic file entity that can go inside an RO-Crate.

public class File : FileOrDir
Inheritance
File
Derived
Inherited Members

Constructors

File()

public File()

File(ROCrate?, string?, JsonObject?, string?, string?, bool, bool)

public File(ROCrate? crate = null, string? identifier = null, JsonObject? properties = null, string? source = null, string? destPath = null, bool fetchRemote = false, bool validateUrl = false)

Parameters

crate ROCrate
identifier string
properties JsonObject
source string
destPath string
fetchRemote bool
validateUrl bool

Methods

Deserialize(string, ROCrate)

Create a File from JSON properties.

public static File? Deserialize(string entityJson, ROCrate roCrate)

Parameters

entityJson string

The JSON representing the File

roCrate ROCrate

The RO-Crate for the File

Returns

File

The deserialised File

Serialize()

Convert File to JSON string.

public override string Serialize()

Returns

string

The File as a JSON string.

Write(string)

Write file contents to the specified path. e.g. The root path of an RO-Crate.

If the file is a remote file, and fetchUrl is set to true, the file will be downloaded under "basePath".

If the file is on disk, it will be copied to a new location under "basePath".

In either case, the file will be saved to "basePath/Id"

public override void Write(string basePath)

Parameters

basePath string

The path the file will be written to.

Examples

var url = "https://hdruk.github.io/hutch/docs/devs";
var fileName = url.Split('/').Last();
var fileEntity = new Models.File(
   new ROCrate(),
   source: url,
   validateUrl: true,
   fetchRemote: true);
fileEntity.Write("myCrate");