All files / src/Repository UploadModels.ts

100% Statements 11/11
100% Branches 0/0
100% Functions 1/1
100% Lines 11/11
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114                    1x                                             1x             1x                     1x                     1x                                     1x             1x                                     3x 3x 3x 3x      
 
/**
 * @module Content
 */ /** */
 
import { IContent, SavedContent } from '../Content';
import { IODataParams } from '../ODataApi/index';
 
export type WithParentContent<T> = T & { Parent: SavedContent };
 
export class UploadOptions<T extends IContent> {
    /**
     * The type of the content to upload, usually should be 'File'
     */
    public ContentType: { new(...args: any[]): T };
    /**
     * The property to save the Binary data to, usually 'Binary'
     */
    public PropertyName: string;
    /**
     * Sets if the target content should be overwritten
     */
    public Overwrite: boolean;
    /**
     * Additional options to post
     */
    public Body?: any;
    /**
     *
     */
    public OdataOptions?: IODataParams<T>;
}
 
export class UploadFileOptions<T extends IContent> extends UploadOptions<T> {
    /**
     * The File instance to be posted
     */
    public File: File;
}
 
export class UploadTextOptions<T extends IContent> extends UploadOptions<T> {
    /**
     * The text data that will be saved to the binary field
     */
    public Text: string;
    /**
     * The name of the file
     */
    public FileName: string;
}
 
export class UploadFromEventOptions<T extends IContent> extends UploadOptions<T> {
    /**
     * The DragEvent to work with. File data will be extracted from it's 'dataTransfer' item.
     */
    public Event: DragEvent;
    /**
     * Option if folders should be created as well.
     */
    public CreateFolders: boolean;
}
 
export class UploadProgressInfo<T extends IContent> {
    /**
     * Basic info about the created Content
     */
    public CreatedContent: SavedContent<T>;
    /**
     * Total chunks count
     */
    public ChunkCount: number;
    /**
     * Uploaded chunks
     */
    public UploadedChunks: number;
    /**
     * Flag that indicates if the upload has been completed
     */
    public Completed: boolean;
}
 
export class SaveBinaryFileOptions {
    /**
     * The File to be saved
     */
    public File: File;
}
 
export class UploadResponse {
    /**
     * The ID of the created Content
     */
    public ContentId: number;
    /**
     * The Chunk token that can be used during upload
     */
    public ChunkToken: string;
    /**
     * Flag that indicates if the Content should be finialized after upload
     */
    public MustFinialize: boolean;
    /**
     * Flag that indicates if the Content should be checked in after upload
     */
    public MustCheckin: boolean;
 
    constructor(...args: any[]) {
        this.ContentId = parseInt(args[0], 0);
        this.ChunkToken = args[1];
        this.MustFinialize = args[2];
        this.MustCheckin = args[3];
    }
}