Add backload for multiple file upload

This commit is contained in:
2016-01-27 11:06:47 -05:00
parent 2c73fb6883
commit 37a7a24436
261 changed files with 28994 additions and 96 deletions
+203
View File
@@ -0,0 +1,203 @@
<?xml version="1.0"?>
<!-- Default configuration options for the Backload component. Insert only the settings you want to change in your Web.Backload.config file.
// Remarks: The server side Backload handler supports very fine granulated and complex storage structures (folders and database tables).
// These storage structures can be influenced server and client side. On the server side you can set up root folders (web.config), on the client you set up context specific subfolders (see example below).
// The good thing: You do not have to use all this stuff. Just omit these settings to use the default simple and flat structure. Everything is stored withing the ~/files folder by default.
// Client side parameters: objectContext and uploadContext (see Example):
// The parameters objectContext and uploadContext are optional. You do not have to include them in the request.
// Basically they influence the storage location on the server, regardless if it is a database or folder structure.
// Server side settings: filesRoot, objectsRoot and content type specific subfolders:
// filesRoot is the root folder for all uploads. objectsRoot is a subfolder an can be ommitted if you do not need it.
// Set up content type specific sub folders, if you want to filter and store files of a specific content into separate subfolders. Example: Store images into an images subfolder (content-types: images/jpeg, images/png, etc. typeFragment: images/). See also example in the contentTypes section.
// Example:
// You want to set up an artist library were users are able to store content (songs, images, videos, other files).
// You want to store the different content in separate subfolders of a root artist folder, where any content belonging to this specific artist is stored.
// Your servers folder structure: [filesRoot]/[objectsRoot]/[objectContext]/[uploadContext] (e.g. ~/files/artists/michealjackson/videos) where [filesRoot] and [objectsRoot] are set up server side in the web.config.
// The objectContext will be the artist. It must be a unique name (e.g. michealjackson) or id. Any uploaded files related to this artist will be stored within a location of this unique id or name.
// UploadContext values are the different content types in this example (e.g. songs, images, videos, other) and result into a subfolder or different datatable.
// If you use separate client side upload controls for the different content, you can simply include hidden input fields. The client jQuery File Upload control will automatically transmit hidden input files to the server. But if you manually perform a ajax request, you have to set these parametes by hand.
// objectContext, uploadContext and fileName can be send in the url as a querystring or in the body (form).
// Note: The subfolder structure can be even more complex: uploadContext supports subfolders within subfolders (e.g. /songs/mp3, /songs/wav, etc.). Simply separate the subfolders by semicolon. Use this example pattern as the value of uploadContext: value="songs;mp3" or value="songs;wav".
// Note also: You can also set up a content type specific subfoldering on the sefrver within the web.config (examples).
// NOTE: This file is not intended to be used directly. Copy the relevant parts to your web.Backload.config file and make your settings in that file.
// The settings in this file are the default values. You do not need to set this values agein. See Example 01 on Github.
-->
<!--
backload: // Basic settings for the Backload component library. TIP: You do not need to include any of these setting in your web.config or external config file, if these default settings fit your needs.
storageContext: // Files may be stored in the file system or in a cloud storage [Default: "Filesystem"]
Filesystem // Saves uploaded files in the file system (or SMB/unc shared folder) [Default]
Cloud // Saves uploaded files to a cloud storage.
enableIntegratedHandler: // By default the internal file upload handler is running and ready to receive incoming files or requests. This enables us zero configuration. If you want to set up your own controller in order to do some business logic, set this to "false". [Default: "true"]
webFilesRoot: // Leave this an empty string, if filesRoot is relative to the web root (starts with '~/', see filesRoot). Usually used with UNC pathes or absolute local pathes (see filesRoot) and virtual directories in IIS. WebFilesRoot can be an absolute web url to the files root (e. g. "http://myfiles.filestore.com/files/" or the name of a virtual directory in IIS [Default: ""]
uniqueFileNames: // Generates unique file names based on guids [Default: "false"]
keepOrgFileNames: // Only applies, if you use the uniqueFileNames option. If set to true, the original file name will be stored (subfolder: _mappings) [Default: "false"]
getInclSubFolders:// On a GET request (return links to uploaded files) only the upload root folder (default filesRoot) is searched for uploaded files. Set to true in order to include subfolders. (Example: A content-type specific subfolder is set to "pdffiles" the search will find files within this subfolder. There are several ways set up subfolders, e.g. uploadContext and objectContext) [Default: "false"]
returnExtraInfo: // We use this setting, to return internal information for the jQuery File Upload Plugin. If you do not want this, set it to "none" [Default: "basic"]
base64MaxSize: // Max length of a base64 encoded embedded data url. Only required if a url pattern is set to return a base64 string in kb (e.g. thumbsUrlPattern="{base64}") [Default="1000" = 1MB].
eventing: // In your custom code you can bind an handler to events. If this option is set to true, events will be fired [Default="false"].
plugin: // Defines the default Json output format. You can overwrite the Json output within your OutgoingResponse extension. See examples [Default: "Auto"]
deleteUrlPattern:
fileUrlPattern:
thumbsUrlPattern: // This attribute sets the pattern of the url returned back to the client in order to download or delete a file. You can use the shortcuts described below. If you do not set this attribute, a direct link is returned by default. If you do not want to return a url, set this to an empty string or use the shortcut {none} (e.g. thumbsUrlPattern="{none}" [Default (GET):"{url}", Default (DELETE):"{Backload}"].
[not set],{url} // If you want a direct link to download the file, do NOT set this value or set the shortcut {url} (e.g. fileUrlPattern="{url}". You do not need to set this value as this is the default for GET requests (DELETE requests: if not set {Backload} is the default).
[empty],{none} // If you do not want a url to be returned for GET or DELETE requests, set this attribute to an empty string or use the shortcut {none} (e.g. fileUrlPattern="").
{Backload} // If you want the file to be returned/deleted by the Backload component, set it to the shortcut {Backload} (Default for the deleteUrlPattern. An explicit file single file request (GET/DELETE with a filename) will now be handled as any other request by the Backload component. You can use your extensions like you are used to. We added an additional extension for the Get file requests: IGetFileRequest. Backloads internal handler has the following pattern (see below) fileUrlPattern="~/Backload/UploadHandler?{fileName}&{objectContext}&{uploadContext}&{content} (empty values are not send back). "{Backload}" is the default for the deleteUrlPattern.
[pattern] // You can define your own pattern for urls returned to the client, for example if you want to use your own download handler.
// Use the shortcuts below (Example: thumbsUrlPattern="http://downloads.myweb.com?file={fileName}&path={full}&preview&foo={query:bar}")
// "~/": Relative to web root (Replacement example http://localhost/).
// {fileName}: Name of the file as a full query (Example:{fileName} => fileName=somepic.jpg).
// {name}: Name of the file (Example:{name} => somepic.jpg).
// {root}: Root storage folder path (Replacement example: files/uploads/)
// {objectContext} If you send an objectContext with your request (see examples for more on this)
// {uploadContext} If you send an uploadContext with your request (see examples for more on this)
// {content} For a content type subfolders, if you set up this feature
// {full} Shortcut for [root]/[objectContext]/[uploadContext]/[content]/
// {base64} Encodes the data (bytes) as a base64 string and includes it in the JSON response. Limited to 256 kb file size, switches to {Backload} if bigger. Saves file requests but blows up the JSON output (not deleteUrlPattern).
// {query:all} If you send custom querystrings along with your request all will be returned in the url.
// {query:key} The custom querystring with this key will be returned. (Example: {query:foo} => &foo=bar)
xmlns:*, xsi:* // No custom setting. Used for schema validation and Visual Studio intellisence.
-->
<backload storageContext="Filesystem" enableIntegratedHandler="true" webFilesRoot="" uniqueFileNames="false" keepOrgFileNames="false" getInclSubFolders="true" returnExtraInfo="basic" plugin="JQueryFileUpload" deleteUrlPattern="{Backload}" filesUrlPattern="{url}" thumbsUrlPattern="{url}" base64MaxSize="1000" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:name="urn:backload-schema" xsi:noNamespaceSchemaLocation="Web.Backload.xsd" >
<!--
fileSystem: Sets the parameters for the dedicated storage location Filesystem or Database (EntityFramework):
filesRoot: // Root upload folder. If the value starts with '~/' (e.g. ~/files) the path is relative to the web root, otherwise set an absolute local path (e.g. d:/files) [Default: "~/Files"].
usersRoot: // Special subfolder within the filesRoot to store user related files like photos etc. Set it to usersRoot="" if you do not need this subfolder [Default: ""]
objectsRoot: // Subfolder within the filesRoot (e.g. "uploads"). Set it to objectsRoot="" if you do not need a subfolder [Default: ""].
copiesRoot: // Root of a folder where Backload stores a copy of an uploaded file, if set to a none empty string, else no copies were stored. If the value is empty ("") not copies are stored. If the value starts with '~/' (e.g. ~/copies) the path is relative to the web root. if the value not starts with '~/' and it isn't an absolute local path, the value will be treated as a subfolder to filesRoot ('copies' -> ~/files/copies). Otherwise set an absolute local path (e.g. d:/backup) [Default: ""].
chunkPathPrefix: // Temporary folder prefix if file chunks are uploaded into the upload folder before they are merged [Default: "_____"].
database:
assemblyName: // Name of the assembly where the DBContext class is defined. You can leave this an empty string, if it is defined in the executing (caller of the file upload handler library) assembly [Default: ""]
dbContext: // Full qualified name of the DBContext derived class [Default: ""]
entitySetName: // Name of the root entity where the files will be stored directly or where the navigation begins (with navigation properties [Default: "Files"]
primaryKeyName: // Name of the primary key of the root entity (separate multiple keys by comma [Default: "ID"]
-->
<fileSystem filesRoot="~/Files" usersRoot="" objectsRoot="" copiesRoot="" chunkPathPrefix="_____" />
<database assemblyName="" dbContext="" entitySetName="" primaryKeyName="ID" />
<!--
security: Security related settings. By default there are no restrictions. If you need a deeper control, set up your own controller to receive the request, do the authentication/authorization and then call the handler.
forceObjectContext: // A request must always include an none empty objectContext parameter (query or form) to be valid. If you use "objectContext" to store/retirieve user related files, a malicious request could reveal some other users files, if forceObjectContext is false [Default:"false"]
allowAnonymous: // True: Anyone is allowed, false: The user must be authenticated [Default: "true"]
allowedDownloadRoles: // By default there are no restrictions on who can download files by a GET request. You can change this by adding a comma separated list of roles [Default: "*"]
allowedUploadRoles: // By default there are no restrictions on who can upload files whithin a POST/PUT request. You can change this by adding a comma separated list of roles [Default: "*"]
allowedDeleteRoles: // By default there are no restrictions on who can delete files by a DELETE request. You can change this by adding a comma separated list of roles [Default: "*"]
cors: // Enables/disables and configures CROSS-ORIGIN RESOURCE SHARING (CORS). CORS is used in environments, where file requests (e.g. GET) come from diffenrent domains (e.g. client: http://www.yourwebsite.com, Backload: http://fileservice.com/Backload/Filehandler ).
enabled: // To enable CORS requests set this attribute to true [Default=°false°]</xs:documentation>
allowedDomains: // Comma-separated list of allowed domains for client side requests or "*" to allow all client side cors requests. Example: allowedOrigin="http://www.myservice.com". [Default="*"]
allowedMethods: // Comma-separated list of allowed http methods. [Default="GET,POST,DELETE"]
allowedHeaders: // Comma-separated list of allowed (none simple) headers. [Default=""]
credentials: // Specifies if a request should send credentials by setting credentials="true" [Default="false"]
maxAge: // Validity period of cors permission settings (in seconds) before the client makes a new request for permissions. Note: Not all clients use this value [Default="36000"]
-->
<security forceObjectContext="false" allowAnonymous="true" allowedDownloadRoles="*" allowedUploadRoles="*" allowedDeleteRoles="*">
<cors enabled="false" allowedDomains="*" allowedMethods="GET,POST,DELETE" allowedHeaders="" credentials="false" />
</security>
<!--
images and thumbnails:
path // Location of the thumbnail within the folder where the main file is stored (thumbnails only). Set to an empty string (path="") to avoid physical storage. [Default: "_thumbs"]
width: // Width or max width (depends on resizeMode) of the resulting image [images range: 20-5000, Default: "1024"; thumbnails range: 20-500, Default: "80"]
height: // Height or max height (depends on resizeMode) of the resulting image [images range: 20-5000, Default: "768"; thumbnails range: 20-500, Default: "60"]
dpi: // Resolution of the resulting image (dots per inch) [Range: 72-600, Default: "96"]
canvasColor: // Background color of the canvas. Only used when resize mode is fit and the image ratio of the source and target image differ. You can also use argb (rgb with alpha channel, e.g. background: #00ffffff (transparent), #80ffffff (white, 50% transparency), #ffffffff (white, opaque)) [Default: #ffffff]
imageType: // Thumnail images must all have the same image type in order the upload handler can find and return the correct thumbnail path [Default: "image/png"]
maxFileSize: // Max file size (bytes) of an image to be processed by the image processing sub pipeline. If the file size is bigger, the image is stored directly bypassing image processing [Default: "0" (unlimited)].
forceImageType // By default the image type of the original image is used. Set this attribute to always output a different type (e.g. image/png or image/jpeg [Defailt: none])
none // Use the original image type
image/png // Files with .png (protable network graphics) extension
image/jpeg // Files with .jpeg or .jpg extension
image/tiff // Files with .tif or .tiff extension
image/gif // Files with .gif extension
image/bmp // Microsoft Bitmap format
resizeMode: // [Default: "none"]
none // Keep original image, no resizing or cropping
ratio // No Canvas, preserves ratio, width and height are max sizes, smaller images are upscaled
maxratio // Same as ratio, but smaller images are not upscaled.
fit // Fit into canvas, preserves ratio, centered on canvas
place, // If the source image is bigger than the canvas same as fit. If it is smaller than the canvas, it will be placed in the center of the canvas without resizing
crop // Placed on canvas, cropped if neccessary with center of the original image
-->
watermark: // Optional watermark image if images are uploaded. Example: watermark="~/Backload/Imaging/watermark.png". [Default: "" (no watermark)].
background: // Optional background image if images are placed or fit onto a canvas. Example: background="~/Backload/Imaging/background.png". [Default: "" (no background image)].
watermarkPosition: // Vertical position of a watermark to be placed on an image[Default: "center"]
top // Top position
center // Center position
bottom // Bottom position
<images width="1024" height="768" dpi="96" canvasColor="#ffffffff" forceImageType="none" resizeMode="none" maxFileSize="0" background="" watermark="", watermarkPosition="center" />
<thumbnails path="_thumbs" width="80" height="60" dpi="96" canvasColor="#ffffffff" resizeMode="place" imageType="image/png" />
<!--
clientFiles: If the bundeling feature is used (@Render.Scripts(), @Render.Styles()), set the appropriate files folder. TIP: Don't forgat to register the bundeling feature in the global.asax. See example project.
scripts: // Scripts folder [Default: "~/Backload/Client"]
styles: // Styles folder [Default: "~/Backload/Client"]
-->
<clientFiles scripts="~/Backload/Client" styles="~/Backload/Client" />
<!--
cacheManager: Adds cache headers to the response if enabled, and returns a http status 304 (Not Modified), if no files have been uploaded or deleted sinse the last request. Note: If you manually or by a different application change files, don't use "lastModified=true", because only requests within Backload's pipeline will be recognized.
lastModified: // If true, includes a Last-Modified header in the response and returns a 304 (Not Modified) if no files where uploaded or deleted since the last request. [Default="false"]
etag: // If true, a ETag is returned in the response on a single file request. In the next request for this file a 304 is returned, if the file has not been modified. [Default="false"]
expires: // Adds an Expires header to the response, if the value is not 0 (seconds). Example: useExpires="3600" (adds 1 hour to the Expires header) [Default="0"]
location: // Adds a Cache-Control header to the response (Please refer to the System.Web.HttpCacheability enumeration for more info) [Default="ServerAndPrivate"]
mustRevalidate // Sets "must-revalidate" within the Cache-Control header. Caches (e.g. Browser, Proxy) are forced to validate if the request has changed [Default="true"].
-->
<cacheManager lastModified="false" etag="false" expires="0" location="ServerAndPrivate" mustRevalidate="true" />
<!--
contentTypes: Enables or disables the extensibility feature globally. If you do not need it, leave it false, because the extensibility framework must not be loaded. Extensions are disabled by default (enabled="false")
enabled: // Enables/disables extensions [Default="false"].
incomingRequest: // If the extensibility feature is enabled (enabled="true") this attribute enables/disables IIncomingRequest extensions [Default="true"].
authorizeRequest: // If the extensibility feature is enabled (enabled="true") this attribute enables/disables IAuthorizeRequest extensions [Default="true"].
getFilesRequest: // If the extensibility feature is enabled (enabled="true") this attribute enables/disables core IGetFilesRequest extensions [Default="true"].
storeFileRequest: // If the extensibility feature is enabled (enabled="true") this attribute enables/disables core IStoreFileRequest extensions [Default="true"].
deleteFilesRequest: // If the extensibility feature is enabled (enabled="true") this attribute enables/disables core IDeleteFilesRequest extensions [Default="true"].
outgoingResponse: // If the extensibility feature is enabled (enabled="true") this attribute enables/disables IOutgoingResponse extensions [Default="true"].
pipelineException: // If the extensibility feature is enabled (enabled="true") this attribute enables/disables IProcessPipelineException extensions [Default="true"].
-->
<contentTypes thumbnailPath="~/Backload/ContentTypes" thumbnailSize="64" useThumbnailCanvas="true">
<!--
New contentType entry (MS Office, OpenOffice, PDF, Textfile are included by default. No need to inlude these anymore):
Use <clear /> to clear all preexisting entries, use <remove name="[entrynmae]" /> to remove a specific entry (Example: <remove name="_AdobePDFFile" /> to remove the predefined PDF type).
Predifined type names: _AdobePDFFile, _MSExcel2003, _MSExcel2012, _MSPowerpoint2003, _MSPowerpoint2012, _MSWord2003, _MSWord2012, _OpenOfficeWriter, _TextFile.
Remarks: _MSxxxx2012 includes all file types from 2007 to 2012 office versions. _MSxxxx2003 includes all file types up to the 2003 office version.
name: // A unique name of the entry
extFragment: // Complete or fragment of the file extension as RegEx string (e.g. .mp finds .mp3, .mp4, .mpeg, etc). Leave it blank, to skip this test.
typeFragment: // Complete or fragment of the content-type as RegEx string (e.g. "mpeg" audio/mpeg, video/mpeg, etc). Leave it blank, to skip this test. Content-types matches are preferred over extension matches.
thumbnail; // Name of the thumbnail image within the content-types thumbnail folder. Special handling of images: Leave it blank, to send a preview of the uploaded image back, or set a thumbnail if you do not want to return a preview.
subfolder; // Subfolder of the object context folder. Has to be set only if files of this content-type should be stored seperatly from other types (e.g. "movies"). [Default: ""]
-->
<!-- <clear /> // Deletes all predefined types -->
<!-- <remove name="..."/> // Removes the type handling for a specific content type. Example: <remove name="_AdobePDFFile"/> -->
<!--
// Example
<remove name="_AdobePDFFile"/> // Remove predefined pdf type handling
<add name="SamplePDFFiles" extFragment=".pdf" typeFragment="application/pdf" thumbnail="PDF.png" subFolder="pdfs" /> // Add special type handling for pdf files. Subfolder will be created, if it doesn't exist
<add name="SampleAllImageFiles" extFragment="" typeFragment="image/" thumbnail="" subFolder="images" /> // Add special content type handling for all image types and store them in a image subfolder. This folder will be automatically created if it doesn't exist. The attribute thumbnail is set to an empty string, so that an image preview will be returned (otherwise a static image)
-->
</contentTypes>
<!--
license: Provided license data for Pro/Enterprise editions only
licensee: // Provided licensee value (usually email adress). Obligatory field in the paid editions.
licenseKey: // Provided license key. Obligatory field in the paid editions.
-->
<license licensee="someone@company.com" licenseKey="{some valid key}" />
</backload>