Skip to content

Adding folios and photos

Enrique Jiménez edited this page Feb 4, 2022 · 6 revisions

The simplest way is to add files is the file manager in NoSql Manager for MongoDB. Remember to check the "Write filenames without the paths."

Another option is to use mongofiles (Download Mongo Database Tools). The PowerShell script below will upload all .jpg files in the current folder.

ls *.jpg -file | % {mongofiles put  -h <HOST> -d ebl -u <USER NAME> -p <PASSWORD> /ssl /sslAllowInvalidCertificates --prefix <BUCKET> --type image/jpeg --replace $_.name}

Photos

Upload photos to the photos GridFS bucket. The filename must be in the form <fragment number>.jpg.

Folios

Scopes

  • Create scope in Auth0 (Authorization > Permissions)
  • Add it to a role (Authorization > Roles)
  • Add a scope to API (Applications > APIs > Dictionary)
  • Change frontend code to request new scope

Upload images

  • Upload images to the folios GridFS bucket. See https://trello.com/c/Qaw9YsG5 for instructions on uploading. The file name must in the form <name>_<number>.jpg.

Update fragments

  • Add folios to fragments (adapt the script as needed):

    function doit() {
        const folios = [
            { number: '001', accession: '', _id: 'BM.45657' },
            { number: '002', accession: '', _id: 'BM.45727' },
            ...
        ]
        const missing = []
        folios.forEach(({number, _id, accession}) => {
            const query = accession !== '' ? {accession: accession} : {_id: _id}
            if(db.getCollection('fragments').findOne(query)) {
                db.getCollection('fragments').update(
                    query,
                    {$push: {
                        folios: {
                            name: 'WMR',
                            number: number
                        }
                    }}
                )
            } else {
                missing.push({number, accession, _id})
            }
        })
        return missing
    }
    doit()
  • Add record:

    db.getCollection('fragments').updateMany(
        {
            'folios.name': 'WRM'
        },
        {
            $push: {
                record: {
                    $each: [{
                        user: 'Mayer',
                        type: 'HistoricalTransliteration',
                        date: '1970-01-01/2018-12-31'
                    }],
                    $position: 0
                }
            }
        }
    )