Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(api-v1): Change API v1 file uploads to work like API v2 #1233

Merged
merged 110 commits into from
Jun 29, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
110 commits
Select commit Hold shift + click to select a range
2e9cbd1
refactor (api-v1): Don't have Knora and Sipi share a filesystem (ongo…
Feb 28, 2019
00bdf43
feature (api-v1): Make bulk import with v2-style file uploads.
Mar 1, 2019
2694c04
test (api-v1): Fix integration test.
Mar 1, 2019
cbca42e
fix (sipi): Remove debugging output.
Mar 1, 2019
b2b6b07
Merge branch 'develop' into wip/535-sipi
Mar 4, 2019
232291a
Merge branch 'develop' into wip/535-sipi
Mar 4, 2019
7d480cf
Merge branch 'develop' into wip/535-sipi
Mar 5, 2019
4f5fed9
feature (api-v1): Change API v1 to use the same Sipi scripts as API v2.
Mar 5, 2019
a072e38
feature (sipi): Support cookie authentication in upload.lua.
Mar 5, 2019
663c0dd
feature (sipi): Remove obsolete routes from Sipi configs.
Mar 5, 2019
bd83b65
refactor (salsah1): Use Sipi /upload route.
Mar 6, 2019
62b6226
Merge branch 'develop' into wip/535-sipi
Mar 20, 2019
f09cfdf
Merge branch 'develop' into wip/535-sipi
Mar 25, 2019
191ae50
Merge branch 'develop' into wip/535-sipi
Mar 25, 2019
810ba55
Merge branch 'develop' into wip/535-sipi
Mar 26, 2019
69313b6
Merge branch 'develop' into wip/535-sipi
Mar 26, 2019
241a226
Merge branch 'develop' into wip/535-sipi
Mar 27, 2019
16cdf2b
Merge branch 'develop' into wip/535-sipi
Mar 28, 2019
c4beaad
fix(sipi): Fix compile error.
Mar 28, 2019
24deb6a
Merge branch 'develop' into wip/535-sipi
Mar 28, 2019
3e02d46
Merge branch 'develop' into wip/535-sipi
Apr 1, 2019
fc70c27
Merge branch 'develop' into wip/535-sipi
Apr 2, 2019
71ed7c1
Merge branch 'develop' into wip/535-sipi
Apr 8, 2019
f5a6ebf
Merge branch 'develop' into wip/535-sipi
Apr 11, 2019
e8902a6
Merge branch 'develop' into wip/535-sipi
Apr 11, 2019
9881151
Merge branch 'develop' into wip/535-sipi
Apr 15, 2019
a08d610
Merge branch 'develop' into wip/535-sipi
Apr 15, 2019
3c60db7
Merge branch 'develop' into wip/535-sipi
Apr 18, 2019
85b3929
Merge branch 'develop' into wip/535-sipi
May 23, 2019
1b936c6
Merge branch 'develop' into wip/535-sipi
May 27, 2019
807fc66
Merge branch 'develop' into wip/535-sipi
May 29, 2019
df591b2
Merge branch 'develop' into wip/535-sipi
Jun 6, 2019
58152e2
Merge branch 'develop' into wip/535-sipi
Jun 6, 2019
0b51310
Merge branch 'develop' into wip/535-sipi
Jun 11, 2019
e74ecb4
Merge branch 'develop' into wip/535-sipi
Jun 14, 2019
b4427f8
Merge branch 'develop' into wip/535-sipi
Jun 14, 2019
e46d27a
Merge branch 'develop' into wip/535-sipi
Jun 14, 2019
16994af
Merge branch 'develop' into wip/535-sipi
Jun 20, 2019
26f2fbd
Merge branch 'develop' into wip/535-sipi
Jun 24, 2019
894e7e1
test(sipi): Fix tests.
Jun 24, 2019
d3c31bd
Merge branch 'develop' into wip/535-sipi
Jun 24, 2019
1992045
Merge branch 'develop' into wip/535-sipi
Jul 2, 2019
ad74cb9
Merge branch 'develop' into wip/535-sipi
Jul 3, 2019
12f9dd5
Merge branch 'develop' into wip/535-sipi
Jul 9, 2019
9121fe0
Merge branch 'develop' into wip/535-sipi
Jul 9, 2019
cb20c2d
Merge branch 'develop' into wip/535-sipi
Jul 19, 2019
34f4632
Merge branch 'develop' into wip/535-sipi
Jul 19, 2019
5526eb0
Merge branch 'develop' into wip/535-sipi
Jul 19, 2019
071ec00
Merge branch 'develop' into wip/535-sipi
Aug 13, 2019
547f74f
Merge branch 'develop' into wip/535-sipi
Aug 13, 2019
eee30f6
Merge branch 'develop' into wip/535-sipi
Aug 19, 2019
c7d1001
Merge branch 'develop' into wip/535-sipi
Aug 26, 2019
bd876e4
Merge branch 'develop' into wip/535-sipi
Aug 27, 2019
9598897
Merge branch 'develop' into wip/535-sipi
Aug 29, 2019
157b6e7
Merge branch 'develop' into wip/535-sipi
Aug 30, 2019
12ca8a5
Merge branch 'develop' into wip/535-sipi
Aug 30, 2019
adb2467
Merge branch 'develop' into wip/535-sipi
Aug 30, 2019
144b7ec
Merge branch 'develop' into wip/535-sipi
Aug 30, 2019
a63b4c1
Merge branch 'develop' into wip/535-sipi
Sep 9, 2019
6da7d76
Merge branch 'develop' into wip/535-sipi
Sep 10, 2019
085a7bc
Merge branch 'develop' into wip/535-sipi
Sep 12, 2019
a694364
Merge branch 'develop' into wip/535-sipi
Sep 24, 2019
d2a044a
Merge branch 'develop' into wip/535-sipi
Sep 26, 2019
065dea1
Merge branch 'develop' into wip/535-sipi
Oct 8, 2019
4e64506
Merge branch 'develop' into wip/535-sipi
Oct 18, 2019
fe087ef
Merge branch 'develop' into wip/535-sipi
Oct 21, 2019
6602a35
Merge branch 'develop' into wip/535-sipi
Oct 22, 2019
d11775e
Merge branch 'develop' into wip/535-sipi
Oct 23, 2019
417233c
Merge branch 'develop' into wip/535-sipi
Nov 4, 2019
440d817
Merge branch 'develop' into wip/535-sipi
Nov 5, 2019
0a0ca9f
Merge branch 'develop' into wip/535-sipi
Nov 8, 2019
fb1e4f5
Merge branch 'develop' into wip/535-sipi
Nov 14, 2019
f2ef95c
Merge branch 'develop' into wip/535-sipi
Nov 15, 2019
7454281
Merge branch 'develop' into wip/535-sipi
Nov 15, 2019
82d6cdf
Merge branch 'develop' into wip/535-sipi
Nov 19, 2019
d04f13c
Merge branch 'develop' into wip/535-sipi
Nov 19, 2019
94af706
Merge branch 'develop' into wip/535-sipi
Nov 28, 2019
6f33295
fix(api-v1): Fix compile errors.
Nov 28, 2019
1c99630
fix(settings): Remove obsolete settings.
Nov 28, 2019
58134fb
fix(api-v1): Accept image/jpx MIME type.
Nov 28, 2019
3e391f7
Merge branch 'develop' into wip/535-sipi
Nov 28, 2019
7260876
fix(settings): Fix typo.
Nov 28, 2019
e36c1a6
Merge branch 'develop' into wip/535-sipi
Dec 2, 2019
bc038d7
Merge branch 'develop' into wip/535-sipi
Dec 3, 2019
5ebb02c
Merge branch 'develop' into wip/535-sipi
Dec 10, 2019
6d824fe
Merge branch 'develop' into wip/535-sipi
Dec 17, 2019
baf7218
Merge branch 'develop' into wip/535-sipi
Dec 17, 2019
7b186e2
Merge branch 'develop' into wip/535-sipi
Dec 19, 2019
e5f84f6
Merge branch 'develop' into wip/535-sipi
Feb 4, 2020
2ef7ec9
Merge branch 'develop' into wip/535-sipi
Feb 5, 2020
126f640
Merge branch 'develop' into wip/535-sipi
Feb 17, 2020
28ab300
test(api-v1): Disable test.
Feb 18, 2020
7dfaa1e
Merge branch 'develop' into wip/535-sipi
Apr 3, 2020
889762f
Merge branch 'develop' into wip/535-sipi
Apr 17, 2020
946281a
triggering github-ci
subotic Apr 17, 2020
8b31606
ci: add debugging output
subotic Apr 18, 2020
eb9d5b2
build: bump sbt version
subotic Apr 20, 2020
7fdc5ff
ci: add debugging output
subotic Apr 20, 2020
319ee8f
ci: add debugging output
subotic Apr 20, 2020
b88a982
ci: add debugging output
subotic Apr 20, 2020
0541ee1
ci: add debugging output
subotic Apr 20, 2020
ac3f02e
Merge branch 'develop' into wip/535-sipi
subotic Apr 21, 2020
e2ae012
Merge branch 'develop' into wip/535-sipi
Apr 29, 2020
de9222b
Merge branch 'develop' into wip/535-sipi
May 13, 2020
c0f1638
Merge branch 'develop' into wip/535-sipi
May 13, 2020
049e2c4
Merge branch 'develop' into wip/535-sipi
Jun 24, 2020
5fcf0c7
build: bump sipi version
subotic Jun 25, 2020
d208857
build: bump sipi version
subotic Jun 25, 2020
bd9d97a
Merge branch 'develop' into wip/535-sipi
Jun 29, 2020
dbc9f74
Merge branch 'develop' into wip/535-sipi
Jun 29, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -210,3 +210,4 @@ YourKit supports open source projects with its full-featured Java Profiler.
YourKit, LLC is the creator of <a href="https://www.yourkit.com/java/profiler/">YourKit Java Profiler</a>
and <a href="https://www.yourkit.com/.net/profiler/">YourKit .NET Profiler</a>,
innovative and intelligent tools for profiling Java and .NET applications.

12 changes: 11 additions & 1 deletion docs/src/paradox/00-release-notes/next.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,17 @@ Also, please change the **HINT** to the appropriate level:

- MAJOR: Separate the `knora-admin` ontology from `knora-api` (@github[#1263](#1263)).
Existing repositories must be updated; see `upgrade/1263-knora-admin` for instructions.

- FEATURE: Add support for searching for specific list values in Gravsearch for both the simple and complex schema (@github[#1314](#1314)).

- REFACTOR: List value responses contain the list node's label in the simple schema only (@github[#1321](#1321))

- MAJOR: Change API v1 file uploads to work like API v2 (@github[#1233](#1233)). To enable
Knora and Sipi to work without sharing a filesystem, the procedure
for uploading files in API v1 has changed; see
Copy link

@gfoo gfoo Mar 8, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tow work -> to work typo master has said :)

@ref:[Adding Resources with Image Files](../03-apis/api-v1/adding-resources.md#adding-resources-with-image-files)
and @ref:[Bulk Import with Image Files](../03-apis/api-v1/adding-resources.md#bulk-import-with-image-files).
Also, for consistency with API v2 responses, the `temporaryBaseIIIFUrl` returned by the Sipi
`/upload` route no longer includes the image filename; see
@ref:[Upload Files to Sipi](../03-apis/api-v2/editing-values.md#upload-files-to-sipi).

148 changes: 72 additions & 76 deletions docs/src/paradox/03-apis/api-v1/adding-resources.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,67 +49,53 @@ The request header's content type has to be set to `application/json`.

## Adding Resources with Image Files

Certain resource classes can have attached image files. There are two ways to
attach a file to a resource: Either by submitting directly the binaries of the file in a
an HTTP Multipart request, or by indicating the location of the file. The two cases are referred to
as non-GUI case and GUI case (see @ref:[Sipi and Knora](../../07-sipi/sipi-and-knora.md)).

### Including the binaries (non-GUI case)

In order to include the binaries, a HTTP Multipart request has to be
sent. One part contains the JSON (same format as described for
[Adding Resources Without Images Files](#adding-resources-without-a-digital-representation))
and has to be named `json`. The other part contains the file's name, its binaries, and its mime type
and has to be named `file`. The following example illustrates how to
make this type of request using Python 3:

```python
#!/usr/bin/env python3

import requests, json

# a Python dictionary that will be turned into a JSON object
resourceParams = {
'restype_id': 'http://www.knora.org/ontology/test#testType',
'properties': {
'http://www.knora.org/ontology/test#testtext': [
{'richtext_value': {'utf8str': "test"}}
],
'http://www.knora.org/ontology/test#testnumber': [
{'int_value': 1}
]
},
'label': "test resource",
'project_id': 'http://rdfh.ch/projects/testproject'
}

# the name of the file to be submitted
filename = "myimage.jpg"
The first step is to upload an image file to Sipi, using a
`multipart/form-data` request, where `sipihost` represents the host and
port on which Sipi is running:

# a tuple containing the file's name, its binaries and its mimetype
file = {'file': (filename, open(filename, 'rb'), "image/jpeg")} # use name "file"
```
HTTP POST to http://sipihost/upload?token=TOKEN
```

# do a POST request providing both the JSON and the binaries
r = requests.post("http://host/v1/resources",
data={'json': json.dumps(resourceParams)}, # use name "json"
files=file,
auth=('user', 'password'))
The `TOKEN` is the `sid` returned by Knora in response to the
client's login request (see @ref:[Authentication](authentication.md)).
The request must contain a body part providing the file as well as a parameter
`filename`, providing the file's original filename, which both Knora and Sipi will
store; these filenames can be descriptive and need not be unique.

Sipi will then convert the uploaded image file to JPEG 2000 format and store
it in a temporary location. If this is successful, it will return a JSON
response that looks something like this:

```json
{
"uploadedFiles": [{
"originalFilename": "manuscript-1234-page-1.tiff",
"internalFilename": "3UIsXH9bP0j-BV0D4sN51Xz.jp2",
"temporaryBaseIIIFUrl": "http://sipihost/tmp"
}]
}
```

Please note that the file has to be read in binary mode (by default it
would be read in text mode).
This provides:

### Indicating the location of a file (GUI case)
- the `originalFilename`, which we submitted when uploading the file
- the unique `internalFilename` that Sipi has randomly generated for the file
- the `temporaryBaseIIIFUrl`, which we can use to construct a IIIF URL for
previewing the file

This request works similarly to
[Adding Resources Without Image Files](#adding-resources-without-a-digital-representation). The JSON format is described
in the TypeScript interface `createResourceWithRepresentationRequest` in
module `createResourceFormats`. The request header's content type has to
set to `application/json`.
The client may now wish to get a thumbnail of the uploaded image, to allow
the user to confirm that the correct files have been uploaded. This can be done
by adding the filename and IIIF parameters to `temporaryBaseIIIFUrl`. For example, to get
a JPG thumbnail image whose width and height are at most 128 pixels wide, you would request
`http://sipihost/tmp/3UIsXH9bP0j-BV0D4sN51Xz.jp2/full/!128,128/0/default.jpg`.

In addition to [Adding Resources Without Image Files](#adding-resources-without-a-digital-representation), the
(temporary) name of the file, its original name, and mime type have to
be provided (see @ref:[GUI Case](../../07-sipi/sipi-and-knora.md#gui-case)).
The request to Knora works similarly to
[Adding Resources Without Image Files](#adding-resources-without-image-files),
with the addition of `file`, whose value is the `internalFilename` that Sipi returned.
See the TypeScript interface `createResourceWithRepresentationRequest` in
module `createResourceFormats` for details. The request header's content type must be
set to `application/json`.

## Response to a Resource Creation

Expand All @@ -124,7 +110,7 @@ The JSON format of the response is described in the TypeScript interface
## Changing a Resource's Label

A resource's label can be changed by making a PUT request to the path
segments `resources/label`. The resource's Iri has to be provided in the
segments `resources/label`. The resource's IRI has to be provided in the
URL (as its last segment). The new label has to submitted as JSON in the
HTTP request's body.

Expand Down Expand Up @@ -152,18 +138,24 @@ Only system or project administrators may use the bulk import.
The procedure for using this feature is as follows
(see the @ref:[example below](#bulk-import-example)).

1. Make an HTTP GET request to Knora to @ref:[get XML schemas](#1-get-xml-schemas) describing
the XML to be provided for the import.
2. @ref:[Generate an XML import document](#2-generate-xml-import-document) representing the
data to be imported, following the Knora import schemas that were generated in step 1.
You will probably want to write a script to do this. Knora is not involved in this step.
If you are also importing image files, this XML document needs to
@ref:[contain the filesystem paths](#bulk-import-with-image-files) of those files.
3. @ref:[Validate your XML import document](#3-validate-xml-import-document), using an XML schema validator such as
[Apache Xerces](http://xerces.apache.org) or [Saxon](http://www.saxonica.com), or an
XML development environment such as [Oxygen](https://www.oxygenxml.com). This will
help ensure that the data you submit to Knora is correct. Knora is not involved in this step.
4. @ref:[Submit the XML import document to Knora](#4-submit-xml-import-document-to-knora).
1. Make an HTTP GET request to Knora to @ref:[get XML schemas](#1-get-xml-schemas) describing
the XML to be provided for the import.

2. If you are importing image files, @ref:[upload files to Sipi](#2-upload-files-to-sipi).

3. @ref:[Generate an XML import document](#3-generate-xml-import-document) representing the
data to be imported, following the Knora import schemas that were generated in step 1.
You will probably want to write a script to do this. Knora is not involved in this step.
If you are also importing image files, this XML document needs to
@ref:[contain the filenames](#bulk-import-with-image-files) that Sipi returned
for the files you uploaded in step 2.

4. @ref:[Validate your XML import document](#4-validate-xml-import-document), using an XML schema validator such as
[Apache Xerces](http://xerces.apache.org) or [Saxon](http://www.saxonica.com), or an
XML development environment such as [Oxygen](https://www.oxygenxml.com). This will
help ensure that the data you submit to Knora is correct. Knora is not involved in this step.

5. @ref:[Submit the XML import document to Knora](#5-submit-xml-import-document-to-knora).

In this procedure, the person responsible for generating the XML import
data need not be familiar with RDF or with the ontologies involved.
Expand Down Expand Up @@ -208,7 +200,12 @@ containing three files:

- `knoraXmlImport.xsd`: The standard Knora XML import schema, used by all XML imports.

#### 2. Generate XML Import Document
#### 2. Upload Files to Sipi

See @ref:[Upload Files to Sipi](../api-v2/editing-values.md#upload-files-to-sipi) in
the Knora API v2 documentation.

#### 3. Generate XML Import Document

We now convert our existing data to XML, probably by writing a custom
script. The resulting XML import document could look like this:
Expand Down Expand Up @@ -341,7 +338,7 @@ This illustrates several aspects of XML imports:
- A text value can have a `lang` attribute, whose value is an ISO 639-1
code specifying the language of the text.

#### 3. Validate XML Import Document
#### 4. Validate XML Import Document

You can use an XML schema validator such as [Apache Xerces](http://xerces.apache.org) or
[Saxon](http://saxon.sourceforge.net/), or an XML development environment
Expand All @@ -354,7 +351,7 @@ For example, using Saxon:
java -cp ./saxon9ee.jar com.saxonica.Validate -xsd:p0801-biblio.xsd -s:data.xml
```

#### 4. Submit XML Import Document to Knora
#### 5. Submit XML Import Document to Knora

To create these resources in Knora, make an HTTP post request with the XML import document
as the request body. The URL must specify the (URL-encoded) IRI of the project in which
Expand Down Expand Up @@ -411,8 +408,8 @@ contains the IRI of the target resource.

To attach an image file to a resource, we must provide the
element `knoraXmlImport:file` before the property elements. In this
element, we must give the absolute filesystem path to the file that
should be attached to the resource, along with its MIME type:
element, we must provide a `filename` attribute, containing the `internalFilename`
that Sipi returned for the file in @ref:[2. Upload Files to Sipi](#2-upload-files-to-sipi).

```xml
<?xml version="1.0" encoding="UTF-8"?>
Expand All @@ -427,7 +424,7 @@ should be attached to the resource, along with its MIME type:
</incunabula:book>
<incunabula:page id="test_page">
<knoraXmlImport:label>a page with an image</knoraXmlImport:label>
<knoraXmlImport:file path="/usr/local/share/import-images/incunabula/12345.tiff" mimetype="image/tiff"/>
<knoraXmlImport:file filename="67SEfNU1wK2-CSf5abe2eh3.jp2"/>
<incunabula:origname knoraType="richtext_value">Chlaus</incunabula:origname>
<incunabula:pagenum knoraType="richtext_value">1a</incunabula:pagenum>
<incunabula:partOf>
Expand All @@ -438,6 +435,5 @@ should be attached to the resource, along with its MIME type:
</knoraXmlImport:resources>
```

During the processing of the bulk import, Knora will
communicate the location of file to Sipi, which will convert it to JPEG 2000
for storage.
During the processing of the bulk import, Knora will ask Sipi for the rest of the
file's metadata, and store that metadata in a file value attached to the resource.
51 changes: 10 additions & 41 deletions docs/src/paradox/03-apis/api-v1/changing-values.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,52 +56,21 @@ has to be used in order to create a new value (all these TypeScript interfaces a

## Modifying a File Value

In order to exchange a file value (digital representation of a
resource), the path segment `filevalue` has to be used. The IRI of the
resource whose file value is to be exchanged has to be appended:
To change a file value, the client first uploads the new file to
Sipi, following the procedure described in
@ref:[Adding Resources with Image Files](adding-resources.md#adding-resources-with-image-files).

Then the client sends a request to Knora, using this following route:

```
HTTP PUT to http://host/filevalue/resourceIRI
```

Please note that the resource IRI has to be URL encoded.

There are two ways to change a file of a resource: Either by submitting
directly the binaries of the file in a HTTP Multipart request or by
indicating the location of the file. The two cases are referred to as
non-GUI case and GUI case (TODO: add a link to "Sipi and Knora").

### Including the binaries (non-GUI case)

Here, a HTTP MULTIPART request has to be made simply providing the
binaries (without JSON):

```python
#!/usr/bin/env python3

import requests, json, urllib

# the name of the file to be submitted
filename = 'myimage.tif'

# a tuple containing the file's name, its binaries and its mimetype
files = {'file': (filename, open(filename, 'rb'), "image/tiff")}

resIri = urllib.parse.quote_plus('http://rdfh.ch/xy')

r = requests.put("http://host/filevalue/" + resIri,
files=files)
```

Please note that the file has to be read in binary mode (by default it
would be read in text mode).

### Indicating the location of a file (GUI case)

Here, simply the location of the new file has to be submitted as JSON.
The JSON format is described in the TypeScript interface
`changeFileValueRequest` in module `changeValueFormats`. The request
header's content type has to set to `application/json`.
Here, `resourceIRI` is the URL-encoded IRI of the resource whose file value is
to be changed. The body of the request is a JSON object described in the TypeScript
interface `changeFileValueRequest` in module `changeValueFormats`, and contains
`file`, whose value is the `internalFilename` that Sipi returned. The request header's
content type must be set to `application/json`.

## Response on Value Change

Expand Down
4 changes: 2 additions & 2 deletions docs/src/paradox/03-apis/api-v2/editing-values.md
Original file line number Diff line number Diff line change
Expand Up @@ -260,11 +260,11 @@ Sipi then returns a JSON response that looks something like this:
"uploadedFiles": [{
"originalFilename": "manuscript-1234-page-1.tiff",
"internalFilename": "3UIsXH9bP0j-BV0D4sN51Xz.jp2",
"temporaryBaseIIIFUrl": "http://sipihost/tmp/3UIsXH9bP0j-BV0D4sN51Xz.jp2"
"temporaryBaseIIIFUrl": "http://sipihost/tmp"
}, {
"originalFilename": "manuscript-1234-page-2.tiff",
"internalFilename": "2RvJgguglpe-B45EOk0Gx8H.jp2",
"temporaryBaseIIIFUrl": "http://sipihost/tmp/2RvJgguglpe-B45EOk0Gx8H.jp2"
"temporaryBaseIIIFUrl": "http://sipihost/tmp"
}]
}
```
Expand Down
4 changes: 2 additions & 2 deletions docs/src/paradox/05-internals/design/api-v2/sipi.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ are described below.
The `upload.lua` script is available at Sipi's `upload` route. It processes one
or more file uploads submitted to Sipi. It converts uploaded images to JPEG 2000
format, and stores them in Sipi's `tmp` directory. The usage of this script is described in
@ref:[Creating File Values](../../../03-apis/api-v2/editing-values.md#creating-file-values).
@ref:[Upload Files to Sipi](../../../03-apis/api-v2/editing-values.md#upload-files-to-sipi).

Each time `upload.lua` processes a request, it also deletes old temporary files
from `tmp` and (recursively) from any subdirectories. The maximum allowed age of
Expand Down Expand Up @@ -96,7 +96,7 @@ If it encounters an error, it returns `SipiException`.
to create or change a file value. The request includes Sipi's internal filename.
3. During parsing of this JSON-LD request, a `StillImageFileValueContentV2`
is constructed to represent the file value. During the construction of this
object, a `GetImageMetadataRequestV2` is sent to `SipiConnector`, which
object, a `GetFileMetadataRequestV2` is sent to `SipiConnector`, which
uses Sipi's built-in `knora.json` route to get the rest of the file's
metadata.
4. A responder (`ResourcesResponderV2` or `ValuesResponderV2`) validates
Expand Down
28 changes: 7 additions & 21 deletions docs/src/paradox/07-sipi/setup-sipi-for-knora.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,10 @@ Whenever a file is requested from Sipi (e.g. a browser trying to
dereference an image link served by Knora), a preflight function is
called. This function is defined in `sipi.init-knora.lua` present in the
Sipi root directory. It takes three parameters: `prefix`, `identifier`
(the name of the requested file), and `cookie`. File links created by
Knora use the prefix `knora`, e.g.
`http://localhost:1024/knora/incunabula_0000000002.jp2/full/2613,3505/0/default.jpg`.
(the name of the requested file), and `cookie`. The prefix is the shortcode
of the project that the resource containing the file value belongs to.

Given these information, Sipi asks Knora about the current's users
Given this information, Sipi asks Knora about the current's users
permissions on the given file. The cookie contains the current user's
Knora session id, so Knora can match Sipi's request with a given user
profile and determine the permissions this user has on the file. If the
Expand All @@ -60,8 +59,8 @@ refuses to serve the file. However, all of this behaviour is defined in
the preflight function in Sipi and not controlled by Knora. Knora only
provides the permission code.

See @ref:[Sharing the Session ID with Sipi](sipi-and-knora.md#sharing-the-session-id-with-sipi) for more
information about sharing the session id.
See @ref:[Authentication of Users with Sipi](sipi-and-knora.md#authentication-of-users-with-sipi) for more
information about sharing the session ID.

## Using Sipi in Test Mode

Expand All @@ -76,24 +75,11 @@ $ docker run --rm -it --add-host webapihost:$DOCKERHOST -v $PWD/config:/sipi/con
```

Then always the same test file will be served which is included in Sipi. In test mode, Sipi will
not aks Knora about the user's permission on the requested file.

## Using Sipi in production behind a proxy

For SIPI to work with Salsah1 (non-angular) GUI, we need to define an additional set of
environment variables if we want to run SIPI behind a proxy:

- `SIPI_EXTERNAL_PROTOCOL=https`
- `SIPI_EXTERNAL_HOSTNAME=iiif.example.org`
- `SIPI_EXTERNAL_PORT=443`

These variables are only used by `make_thumbnail.lua`:

@@snip[make_thumbnail.lua](../../../../sipi/scripts/make_thumbnail.lua) { #snip_marker }
not ask Knora about the user's permission on the requested file.

## Additional Sipi Environment Variables

Additionaly, these environment variables can be used to further configure sipi:
Additionally, these environment variables can be used to further configure sipi:

- `SIPI_WEBAPI_HOSTNAME=localhost`: overrides `knora_path` in Sipi's config
- `SIPI_WEBAPI_PORT=3333`: overrides `knora_port` in Sipi's config
Expand Down
Loading