Class CloudUploadSession
The server-issued facts about a direct-to-cloud upload, carried in a tamper-proof token so later calls in the same upload cannot change them.
Why this exists. The presign flow is several requests: create, sign
parts, complete, abort. Only create chooses the object key; every later call
receives the key and upload id from the client. Without binding, a caller can
send any key it likes and have parts presigned for it, or complete and abort uploads
it did not start.
This is the Web Forms counterpart of CoreUpload's
CloudUploadSession. It uses MachineKey - the .NET Framework
equivalent of ASP.NET Core Data Protection - so key management follows the
machine key configuration already used for view state and forms authentication.
In a web farm the machine key must be explicitly configured and shared, exactly as
it must be for view state.
Inherited Members
Namespace: AjaxUploader.Security
Assembly: AjaxUploader.dll
Syntax
public sealed class CloudUploadSession
Properties
DeclaredSize
The size declared at create time, so a later call cannot inflate it.
Declaration
public long DeclaredSize { get; set; }
Property Value
| Type | Description |
|---|---|
| long |
ExpiresAtUtc
Absolute expiry, as a UTC tick count.
Declaration
public DateTime ExpiresAtUtc { get; set; }
Property Value
| Type | Description |
|---|---|
| DateTime |
Key
The object key the server chose. Never taken from the client once bound.
Declaration
public string Key { get; set; }
Property Value
| Type | Description |
|---|---|
| string |
UploadId
The provider's upload/session id (S3 uploadId, GCS session, Azure blob).
Declaration
public string UploadId { get; set; }
Property Value
| Type | Description |
|---|---|
| string |
Methods
Issue(string, string, long, TimeSpan?)
Issues a token for an upload the server has just opened.
Declaration
public static string Issue(string uploadId, string key, long declaredSize, TimeSpan? lifetime = null)
Parameters
| Type | Name | Description |
|---|---|---|
| string | uploadId | |
| string | key | |
| long | declaredSize | |
| TimeSpan? | lifetime |
Returns
| Type | Description |
|---|---|
| string |
Validate(string)
Validates a token. Returns null if it is missing, tampered with, issued for another purpose, or expired.
Declaration
public static CloudUploadSession Validate(string token)
Parameters
| Type | Name | Description |
|---|---|---|
| string | token |
Returns
| Type | Description |
|---|---|
| CloudUploadSession |