Define where to store image etc. files on a GN4 server

Build 1501 on 14/Nov/2017  This topic last edited on: 21/Mar/2016, at 18:52

In the standard schema certain content attributes, such as image.thumbnail, image.preview, img.thumbnail,  img.preview… etc are stored in the database (gn_datatable). This is handled by the attribute definition that does not include the gs:volume attribute:

   <xs:element

              name="preview"

              type="dataContent"

              minOccurs="0" nillable="true"

              gs:mimeTypes="image/jpeg image/gif image/png"

              gs:access="Content">

              <xs:annotation>

                <xs:documentation>The image preview. Generated by the import process.</xs:documentation>

                <xs:appinfo>

                  <gs:ui mode="ReadOnly">

                    <gs:template kind="Image"/>

                  </gs:ui>

                </xs:appinfo>

              </xs:annotation>

            </xs:element>

 

If you want to store the binary attributes in the file system, because managing a big database can be an issue, you can change the schema definition, associating a volume to the element.

For example, you can define the preview attribute to save previews on the volume named imagePreviews:

List of steps

1.Add gs:volume with the appropriate volume name to all the attributes you want to store in the file system:

   <xs:element

              name="preview"

              type="dataContent"

              minOccurs="0" nillable="true"

              gs:mimeTypes="image/jpeg image/gif image/png"

              gs:access="Content"

              gs:volume="imagePreviews">

              <xs:annotation>

                <xs:documentation>The image preview. Generated by the import process.</xs:documentation>

                <xs:appinfo>

                  <gs:ui mode="ReadOnly">

                    <gs:template kind="Image"/>

                  </gs:ui>

                </xs:appinfo>

              </xs:annotation>

            </xs:element>

 

2.Import the schema.

3.Make sure the appsettings.xml on the IIS servers and on the BACK4 servers correctly defines the root volumes attribute:

<add key="Db.RootVolumeUrl" value="\\myserver\gn4volumes" />

That's because the application automatically creates the subfolder “imagePreviews” as soon as a new image will be processed and a new preview will be created.

4.Restart BACK4 and IIS.

5.Upload an image, or ingest and image in BACK4

6.Verify that the folder in the volumes is created, and that the preview is there saved.

Note

What about the previews stored in the db? The schema change will not automatically move the previews from the database. You have to run a dedicated srv4 command for this.

Since this operation can take time, it is wise to test the move on selected images, using a search condition (searchimages.xml in the example below) to select the objects to touch.

srv4 changevolume –conditions searchimages.xml -attr image.preview -name imagePreviews

All the image previews are always available, even if you don’t run this command.

The new volume definition is used for new objects, not for the existing ones, unless you run the above command.

Refer to this post for more info about the srv4 commands to manage volumes:

http://forum.teradp.com/topic.asp?TOPIC_ID=737