diff --git a/resources/vue/mixins/courseware/export.js b/resources/vue/mixins/courseware/export.js
index b20a41e59f12ed36cbeca01c6384b7dc255f0f66..845ffe3a841aa8c290239c3767dc52d12689113a 100644
--- a/resources/vue/mixins/courseware/export.js
+++ b/resources/vue/mixins/courseware/export.js
@@ -240,7 +240,7 @@ export default {
             if (fileId) {
                 await this.$store.dispatch('file-refs/loadById', {id: fileId});
                 let fileRef = this.$store.getters['file-refs/byId']({id: fileId});
-                
+
                 let fileRefData = {};
                 fileRefData.id = fileRef.id;
                 fileRefData.attributes = fileRef.attributes;
@@ -311,6 +311,19 @@ export default {
                 fileref.related_block_id = block_id;
                 fileref.id = refs[ref_id].id;
 
+                // Create an empty relationships object to pick and hold selected relationships of the fileref. Because not all of
+                // them are necessary.
+                let relationships = {};
+                // Get terms-of-use id from relationships.
+                if (refs[ref_id].relationships?.['terms-of-use']?.data?.id) {
+                    let terms = {'data' : refs[ref_id].relationships['terms-of-use'].data};
+                    relationships['terms-of-use'] = terms;
+                }
+                // Add relationships to the fileref object if it has some values.
+                if (Object.keys(relationships).length > 0) {
+                    fileref.relationships = relationships;
+                }
+
                 try {
                     await this.loadFolder(folderId);
                     folder = this.folderById({id: folderId});
diff --git a/resources/vue/store/courseware/courseware.module.js b/resources/vue/store/courseware/courseware.module.js
index e5969c82f321065e85458d7b5e0f3a2e1c468a43..bf27447a598a806401c7a6821252bd208a7b4a63 100644
--- a/resources/vue/store/courseware/courseware.module.js
+++ b/resources/vue/store/courseware/courseware.module.js
@@ -310,7 +310,7 @@ export const actions = {
     },
 
     async createFile(context, { file, filedata, folder }) {
-        const termId = file?.relationships['terms-of-use']?.data?.id ?? null;
+        const termId = file?.relationships?.['terms-of-use']?.data?.id ?? null;
         const formData = new FormData();
         formData.append('file', filedata, file.attributes.name);
         if (termId) {