Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
feat(sipi): add storing of original and sidecar (DSP-1318) (#1808)
  • Loading branch information
lrosenth committed Feb 5, 2021
1 parent 826e2ea commit 022ed7e
Show file tree
Hide file tree
Showing 21 changed files with 687 additions and 134 deletions.
4 changes: 2 additions & 2 deletions knora-ontologies/knora-base.ttl
Expand Up @@ -33,7 +33,7 @@

:attachedToProject knora-admin:SystemProject ;

:ontologyVersion "knora-base v9" .
:ontologyVersion "knora-base v10" .



Expand Down Expand Up @@ -1792,7 +1792,7 @@
rdfs:subClassOf :FileValue ,
[ rdf:type owl:Restriction ;
owl:onProperty :pageCount ;
owl:cardinality "1"^^xsd:nonNegativeInteger
owl:maxCardinality "1"^^xsd:nonNegativeInteger
] ,
[ rdf:type owl:Restriction ;
owl:onProperty :dimX ;
Expand Down
70 changes: 65 additions & 5 deletions sipi/scripts/file_info.lua
Expand Up @@ -35,7 +35,21 @@ local IMAGE_JPG = "image/jpeg"
local APPLICATION_XML = "application/xml"
local TEXT_XML = "text/xml"
local TEXT_PLAIN = "text/plain"
local AUDIO_MP3 = "audio/mpeg"
local AUDIO_MP4 = "audio/mp4"
local AUDIO_WAV = "audio/x-wav"
local APPLICATION_PDF = "application/pdf"
local APPLICATION_DOC = "application/msword"
local APPLICATION_DOCX = "application/vnd.openxmlformats-officedocument.wordprocessingml.document"
local APPLICATION_XLS = "application/vnd.ms-excel"
local APPLICATION_XLSX = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
local APPLICATION_PPT = "application/vnd.ms-powerpoint"
local APPLICATION_PPTX = "application/vnd.openxmlformats-officedocument.presentationml.presentation"
local APPLICATION_ZIP = "application/zip"
local APPLICATION_TAR = "application/x-tar"
local APPLICATION_ISO = "application/x-iso9660-image"
local APPLICATION_GZIP = "application/gzip"


local image_mime_types = {
IMAGE_JP2,
Expand All @@ -44,14 +58,36 @@ local image_mime_types = {
IMAGE_JPG
}

local audio_mime_types = {
AUDIO_MP3,
AUDIO_MP4,
AUDIO_WAV
}

local text_mime_types = {
TEXT_PLAIN,
APPLICATION_XML,
TEXT_XML
}

local document_mime_types = {
APPLICATION_PDF
APPLICATION_PDF,
APPLICATION_TAR,
APPLICATION_ZIP,
APPLICATION_ISO,
APPLICATION_GZIP,
APPLICATION_DOC,
APPLICATION_DOCX,
APPLICATION_XLS,
APPLICATION_XLSX,
APPLICATION_PPT,
APPLICATION_PPTX
}

local audio_extensions = {
"mp3",
"mp4",
"wav"
}

local text_extensions = {
Expand All @@ -63,16 +99,37 @@ local text_extensions = {
}

local document_extensions = {
"pdf"
"pdf",
"zip",
"tar",
"iso",
"gz",
"doc",
"docx",
"xls",
"xlsx",
"ppt",
"pptx"
}

function make_image_file_info()
function make_image_file_info(extension)
return {
media_type = IMAGE,
extension = "jp2"
extension = extension
}
end

function make_audio_file_info(extension)
if not table.contains(audio_extensions, extension) then
return nil
else
return {
media_type = AUDIO,
extension = extension
}
end
end

function make_text_file_info(extension)
if not table.contains(text_extensions, extension) then
return nil
Expand Down Expand Up @@ -105,12 +162,15 @@ end
-- a table containing "media_type" and "extension", or false if no supported media type was found.
-------------------------------------------------------------------------------
function get_file_info(filename, mimetype)

local extension = filename:match("^.+%.([^.]+)$")

if extension == nil then
return nil
elseif table.contains(image_mime_types, mimetype) then
return make_image_file_info()
return make_image_file_info(extension)
elseif table.contains(audio_mime_types, mimetype) then
return make_audio_file_info(extension)
elseif table.contains(text_mime_types, mimetype) then
return make_text_file_info(extension)
elseif table.contains(document_mime_types, mimetype) then
Expand Down

0 comments on commit 022ed7e

Please sign in to comment.