-
Notifications
You must be signed in to change notification settings - Fork 73
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow custom metadata when linking a file (#4758)
- Loading branch information
1 parent
c167efe
commit eabbea5
Showing
24 changed files
with
326 additions
and
105 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
.../scala/ch/epfl/bluebrain/nexus/delta/plugins/storage/files/model/FileCustomMetadata.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package ch.epfl.bluebrain.nexus.delta.plugins.storage.files.model | ||
|
||
import ch.epfl.bluebrain.nexus.delta.sourcing.model.Label | ||
import io.circe.Decoder | ||
import io.circe.generic.semiauto.deriveDecoder | ||
|
||
/** | ||
* Custom metadata for a file that can be specified by the user. | ||
*/ | ||
case class FileCustomMetadata( | ||
name: Option[String], | ||
description: Option[String], | ||
keywords: Option[Map[Label, String]] | ||
) | ||
|
||
object FileCustomMetadata { | ||
|
||
implicit val fileUploadMetadataDecoder: Decoder[FileCustomMetadata] = | ||
deriveDecoder[FileCustomMetadata] | ||
|
||
val empty: FileCustomMetadata = FileCustomMetadata(None, None, None) | ||
|
||
} |
31 changes: 19 additions & 12 deletions
31
...ain/scala/ch/epfl/bluebrain/nexus/delta/plugins/storage/files/model/FileDescription.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,40 @@ | ||
package ch.epfl.bluebrain.nexus.delta.plugins.storage.files.model | ||
|
||
import akka.http.scaladsl.model.ContentType | ||
import cats.implicits.catsSyntaxOptionId | ||
import ch.epfl.bluebrain.nexus.delta.plugins.storage.files.UploadedFileInformation | ||
import ch.epfl.bluebrain.nexus.delta.sourcing.model.Label | ||
|
||
case class FileDescription( | ||
filename: String, | ||
keywords: Map[Label, String], | ||
mediaType: Option[ContentType], | ||
description: Option[String], | ||
name: Option[String] | ||
metadata: Option[FileCustomMetadata] | ||
) | ||
|
||
object FileDescription { | ||
def from(file: File): FileDescription = { | ||
from(file.attributes) | ||
} | ||
|
||
def from(fileAttributes: FileAttributes): FileDescription = { | ||
def from(fileAttributes: FileAttributes): FileDescription = | ||
FileDescription( | ||
fileAttributes.filename, | ||
fileAttributes.keywords, | ||
fileAttributes.mediaType, | ||
fileAttributes.description, | ||
fileAttributes.name | ||
FileCustomMetadata( | ||
fileAttributes.name, | ||
fileAttributes.description, | ||
Some(fileAttributes.keywords) | ||
).some | ||
) | ||
|
||
def from(info: UploadedFileInformation): FileDescription = | ||
FileDescription( | ||
info.filename, | ||
Some(info.suppliedContentType), | ||
FileCustomMetadata( | ||
info.name, | ||
info.description, | ||
Some(info.keywords) | ||
).some | ||
) | ||
} | ||
|
||
def from(info: UploadedFileInformation): FileDescription = { | ||
FileDescription(info.filename, info.keywords, Some(info.suppliedContentType), info.description, info.name) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.