Skip to content

Commit

Permalink
Filename redundant property
Browse files Browse the repository at this point in the history
  • Loading branch information
tomcrane committed Apr 29, 2024
1 parent e037baf commit a91b0df
Show file tree
Hide file tree
Showing 9 changed files with 31 additions and 20 deletions.
4 changes: 2 additions & 2 deletions LeedsExperiment/Dashboard/Views/Browse/Binary.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@

<table class="table">
<tr>
<th scope="row">File name</th>
<td>@Model.FileName</td>
<th scope="row">Name</th>
<td>@Model.Name</td>
</tr>
<tr>
<th scope="row">Content type</th>
Expand Down
3 changes: 0 additions & 3 deletions LeedsExperiment/Dashboard/Views/Shared/_ContainerTable.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
<th scope="col">Type</th>
<th scope="col">Created</th>
<th scope="col">LastModified</th>
<th scope="col">Filename</th>
<th scope="col">Content type</th>
<th scope="col">Size</th>
</tr>
Expand All @@ -28,7 +27,6 @@
<td>@StringUtils.GetLocalDate(container.LastModified)</td>
<td></td>
<td></td>
<td></td>
</tr>
}

Expand All @@ -41,7 +39,6 @@
<td>@binary.Type</td>
<td>@StringUtils.GetLocalDate(binary.Created)</td>
<td>@StringUtils.GetLocalDate(binary.LastModified)</td>
<td>@binary.FileName</td>
<td>@binary.ContentType</td>
<td>@StringUtils.FormatFileSize(binary.Size, true)</td>
</tr>
Expand Down
9 changes: 7 additions & 2 deletions LeedsExperiment/Fedora/Abstractions/Binary.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,13 @@ public Binary(FedoraJsonLdResponse jsonLdResponse) : base(jsonLdResponse)
}
}

[JsonPropertyName("filename")]
[JsonPropertyOrder(21)]
/// <summary>
/// The ebucore:filename triple in Fedora.
/// This is here for visibility, but we will not use it in the Storage API - use Name to hold original file name.
///
/// We could validate that it's always the same as Name
/// </summary>
[JsonIgnore]
public string? FileName { get; set; }

[JsonPropertyName("contentType")]
Expand Down
11 changes: 6 additions & 5 deletions LeedsExperiment/Fedora/Abstractions/Resource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,14 @@ protected Resource()

[JsonPropertyName("@id")]
[JsonPropertyOrder(1)]
// The URI for this API
// The URI for this Storage API (accessible to API consumers)
public Uri? PreservationApiUri { get; set; }

[JsonPropertyName("id")]
[JsonPropertyOrder(12)]
// The URI in Fedora (not accessible to API consumers)
public Uri? Location { get; set; }

[JsonPropertyName("type")]
[JsonPropertyOrder(1)]
public string? Type { get; set; }
Expand All @@ -39,10 +44,6 @@ protected Resource()
// Use dc:title on the fedora resource
public string? Name { get; set; }

[JsonPropertyName("id")]
[JsonPropertyOrder(12)]
// The Fedora identifier
public Uri? Location { get; set; }

[JsonPropertyName("objectPath")]
[JsonPropertyOrder(12)]
Expand Down
8 changes: 5 additions & 3 deletions LeedsExperiment/Fedora/Abstractions/Transfer/BinaryFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,12 @@ public class BinaryFile : ResourceWithParentUri
/// <summary>
/// The Original / actual name of the file, rather than the path-safe, reduced character set slug.
/// Goes into Fedora as Content-Disposition
///
/// Going to remove this from the class that represents a file for transfer, because we only want to think about Name
/// </summary>
[JsonPropertyName("fileName")]
[JsonPropertyOrder(13)]
public required string FileName { get; set; }
//[JsonPropertyName("fileName")]
//[JsonPropertyOrder(13)]
//public required string FileName { get; set; }

// NB ^^^ for a filename like readme.txt, Slug, Name and FileName will all be the same.
// And in practice, Name and FileName are going ot be the same
Expand Down
4 changes: 4 additions & 0 deletions LeedsExperiment/Fedora/ApiModel/BinaryMetadataResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ namespace Fedora.ApiModel
{
public class BinaryMetadataResponse : FedoraJsonLdResponse
{
/// <summary>
/// This property is present at ebucore:filename in Fedora RDF.
/// It is present if you gave the binary a content disposition header to set the file name
/// </summary>
[JsonPropertyName("filename")]
[JsonPropertyOrder(201)]
public string? FileName { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ private static void TraverseContainers(
ContentType = binary.ContentType ?? string.Empty,
StorageType = StorageTypes.S3, // shouldn't have to hard code that here, but Binary doesn't have that prop
Digest = binary.Digest,
FileName = binary.FileName!,
// FileName = binary.FileName!,
ExternalLocation = binary.Origin ?? string.Empty // we won't use this because it's the destination
});
}
Expand Down Expand Up @@ -437,7 +437,7 @@ private async Task<ImportSource> GetImportSource(string source, Uri intendedPare
importSource.Files.Add(new BinaryFile
{
Name = nameAndParentPath.Name,
FileName = nameAndParentPath.Name,
// FileName = nameAndParentPath.Name,
Parent = intendedParent,
Path = sourcePath,
StorageType = StorageTypes.S3,
Expand Down
6 changes: 4 additions & 2 deletions LeedsExperiment/Preservation/FedoraWrapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ private async Task<HttpRequestMessage> MakeBinaryPutOrPost(HttpMethod httpMethod
case StorageTypes.S3:
// This should instead reference the file in S3, for Fedora to fetch
// https://fedora-project.slack.com/archives/C8B5TSR4J/p1710164226000799
// ^ not possible rn
// ^ not possible rn - but can use a signed HTTP url to fetch! (TODO)
var s3Uri = new AmazonS3Uri(binaryFile.ExternalLocation);
var s3Req = new GetObjectRequest() { BucketName = s3Uri.Bucket, Key = s3Uri.Key };
var ms = new MemoryStream();
Expand All @@ -362,7 +362,9 @@ private async Task<HttpRequestMessage> MakeBinaryPutOrPost(HttpMethod httpMethod
default:
throw new InvalidOperationException("Unkown storage type " + binaryFile.StorageType);
}
req.Content.WithContentDisposition(binaryFile.FileName);
// req.Content.WithContentDisposition(binaryFile.FileName); // no longer use this property...
// ...but still set the content disposition to give the file within Fedora an ebucore:filename triple:
req.Content.WithContentDisposition(binaryFile.Name);
return req;
}

Expand Down
2 changes: 1 addition & 1 deletion LeedsExperiment/SamplesWorker/Worker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ private BinaryFile MakeBinaryFileFromFileSystem(string localRootPath, Uri fedora
ExternalLocation = localFileInfo.FullName,
Path = pathWithinArchivalGroup,
ContentType = contentType,
FileName = localFileInfo.Name,
// FileName = localFileInfo.Name,
Name = localFileInfo.Name,
StorageType = StorageTypes.FileSystem,
Digest = sha256
Expand Down

0 comments on commit a91b0df

Please sign in to comment.