Create.Course.File

Creates one or more static resource files in the course. This requires the "Files in Course" Default course setting on the site level, and the corresponding "Use files in course" in each individual course.

Uploaded files will be made available under Settings -> Files in the course.

This is not recommeded for use by third party developers.

Input parameters:

Name

Description

Type

M/O

Message Type

Type of the message

Text: "Create.Course.File"

M

SyncKeys

One or more external SyncKeys for the created file(s).

Text

O

SiteId

Site where action will be executed

Int

O

VendorId

VendorId which will be associated with created content

Text

O

UserID

UserID of the owner.

Integer

O/M

UserSyncKey

User SyncKeyID of the owner.

Text

O/M

CourseID

ID of the course,

Text

O/M

CourseSyncKey

SyncKey of the course.

Text

O.M

ParentSyncKey

SyncKey of the folder into which the file is to be added. Default is the root.

Text

O

File

Name of the file(s).

Text.

Must not be blank.

Follow same rules as the UI. Can’t contain invalid characters

M

Notes:

Either UserID or UserSyncKey and CourseID or CourseSyncKey must be specified. This means at least one of each pair is mandatory.

Output

Finished status

If the folder was created successfully, output message contains its path, that can be used to construct URL for accessing the folder from web browser.

  • Returns relative physical path to new folder, for example "\newfile".

Warning status

  • Unable to find some files in the user's site.

  • File doesn't exist.

  • Supplied SyncRefId not found.

Errors status

  • Unable to find any files in the user's site.

  • Invalid format / parameters (different to specified schema).

  • User with specified UserId/UserSyncKey is not valid.

  • User with specified UserId/UserSyncKey is deleted.

  • User with specified UserId/UserSyncKey is external.

  • Course does not exist.

  • Course is external.

  • Course is deleted.

  • Invalid or unknown ParentSyncKey.

  • Unable to find file matching the supplied GUID.

  • Message contains duplicates for syncKeys: {0}. Make sure your syncKeys are globally unique.

  • File name is blank or contains invalid characters.

  • File size exceeds the user's quota.

Sample database content

This section describes example output after successfully creating a new file.

Conditions

Folder hierarchy: parent_folder > new_file

Web files virtual folder for a given user: /data/1/1/

Web files homepage link: https://localhost/data/1/1

Storage

This is how it's being stored in the database:

MessageIdentifierMap

EntityIdentifier

Type

Description

/C[courseId]/parent_folder/new_file

CourseFolder

EntityIdentifier contains physical path suitable to use with PersonalFileHandler class. In code we handle physical paths, so its easier to store it this way. Pair EntityIdentifier and Type is an unique identifier.

MessageLogEntry

Folder visibility

EntityIdentifier

Description

Text

Description

Web

\parent_folder\new_file

Physical path suitable to use with PersonalFileHandler class. In code we handle physical paths, so its easier to store it this way.

/data/1/1/parent_folder/new_file

Relative URL used to construct full URL to a file in the user's public folder.
Sample URL used to navigate to the public folder: https://localhost/data/1/1/parent_folder/new_file

MessageIndexEntry

Folder's SyncKey specified in the message

Type

Value

Description

Existing SyncKey

No changes

No changes to existing row

Not specified - null value

SyncKey

e9f3bc22-d307-48a0-8b4e-0934180df3a4

A row with autogenerated key is being inserted to the table

XML

Schema
<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns="urn:message-schema"
elementFormDefault="qualified"
targetNamespace="urn:message-schema">
<xs:element name="Message">
<xs:complexType>
<xs:sequence>
<xs:element name="SyncKeys" minOccurs="0" maxOccurs="1">
<xs:complexType>
<xs:sequence>
<xs:element name="SyncKey" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute name="ID" type="xs:ID" use="required"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="CreateCourseFile" minOccurs="1" maxOccurs="1">
<xs:complexType>
<xs:sequence>
<xs:choice minOccurs="1" maxOccurs="1">
<xs:element name="UserId" type="xs:integer" />
<xs:element name="UserSyncKey" type="xs:string" />
</xs:choice>
<xs:choice minOccurs="1" maxOccurs="1">
<xs:element name="CourseId" type="xs:integer" />
<xs:element name="CourseSyncKey" type="xs:string" />
</xs:choice>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="Files" minOccurs="1" maxOccurs="1">
<xs:complexType>
<xs:sequence>
<xs:element name="File" minOccurs="1" maxOccurs="unbounded">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute name="ParentSyncKey" type="xs:string" use="optional" />
<xs:attribute name="SyncKeyRef" type="xs:IDREF" use="optional" />
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>


Message content example

File MessageContent
<Message xmlns="urn:message-schema">
<SyncKeys>
<SyncKey ID="ID1">abc</SyncKey>
</SyncKeys>
<CreateCourseFile>
<UserSyncKey>987654321</UserSyncKey>
<CourseId>3</CourseId>
</CreateCourseFile>
<Files>
<File SyncKeyRef="ID1">d83a6745-428c-4afb-a3c8-8ef7ceb8a061</File>
</Files>
</Message>