Notes to Callers
Below are the examples for setting a Location parameter/property.
This property can be set to:
public Location UploadLocation { get; set; }
Public Property UploadLocation As Location
Get
Set
Setting upload location in code:
//Setting a physical path string:
//See below for other path string examples.
fileUploader.UploadLocation = @"c:\SomeFolder\Uploads";
//Setting a virtual path string:
//See below for other path string examples.
fileUploader.UploadLocation = "~/App_Data/Uploads";
//Setting a location provider instance:
//See below for other location provider examples (UNC Path, AmazonS3, AzureBlob etc.).
fileUploader.UploadLocation = new PhysicalLocation
{
Path = @"c:\SomeFolder\Uploads"
};
//Setting a provider string:
//See below for other provider string examples (UNC Path, AmazonS3, AzureBlob etc.).
fileUploader.UploadLocation = @"Type=Physical; Path=c:\SomeFolder\Uploads";
'Setting a location provider instance:
'See below for other location provider examples.
fileUploader.UploadLocation = New PhysicalLocation() With {
.Path = "c:\SomeFolder\Uploads"
}
'Setting a path string:
'See below for other path string examples (UNC Path, AmazonS3, AzureBlob etc.).
fileUploader.UploadLocation = "c:\SomeFolder\Uploads"
'Setting a provider string:
'See below for other provider string examples (UNC Path, AmazonS3, AzureBlob etc.).
fileUploader.UploadLocation = "Type=Physical; Path=c:\SomeFolder\Uploads"
Setting upload location in ASPX markup:
<%--
Setting a physical path string:
See below for other path string examples.
--%>
<GleamTech:FileUploaderControl runat="server"
UploadLocation="c:\SomeFolder\Uploads" />
<%--
Setting a virtual path string:
See below for other path string examples.
--%>
<GleamTech:FileUploaderControl runat="server"
UploadLocation="~/App_Data/Uploads" />
<%--
Setting a provider string:
See below for other provider string examples.
--%>
<GleamTech:FileUploaderControl runat="server"
UploadLocation="Type=Physical; Path=c:\SomeFolder\Uploads" />
Setting a plain string:
Location location;
//Setting a physical path string:
//This is parsed as a PhysicalLocation instance.
location = @"c:\SomeFolder";
//Setting a virtual path string:
//This is parsed as a PhysicalLocation instance and virtual path is resolved on access.
//Note that virtual paths can only be resolved in a web application
//and on Linux paths starting with "/" are physical paths and not virtual paths.
location = "~/SomeFolder";
Dim location As Location
'Setting a physical path string:
'This is parsed as a PhysicalLocation instance.
location = "c:\SomeFolder"
'Setting a virtual path string:
'This is parsed as a PhysicalLocation instance and virtual path is resolved on access.
'Note that virtual paths can only be resolved in a web application
'and on Linux paths starting with "/" are physical paths and not virtual paths.
location = "~/SomeFolder"
Setting a physical location:
Location location;
//Setting a physical location via a PhysicalLocation instance:
location = new PhysicalLocation
{
//Path can also be virtual path string like "~/App_Data/SomeFolder" in a web application.
Path = @"c:\SomeFolder"
};
//Setting a physical location via a provider string (same as above):
location = @"Type=Physical; Path=c:\SomeFolder";
//---------------------------------------
//Setting a physical location via a PhysicalLocation instance, to connect as a specific user:
//UserName can be specified as "Domain\User", "User@Domain" (UPN format), "Machine\User", "User" (local user).
location = new PhysicalLocation
{
Path = @"\\server\share", //a UNC path or a local path
UserName = "USERNAME",
Password = "PASSWORD"
};
//Setting a physical location via a provider string, to connect as a specific user (same as above):
//In a provider string, if a value contains semi-colon character, that value should be enclosed
//in single quotes (e.g. Password='PASS;WORD') or double quotes (e.g. Password="PASS;WORD").
location = @"Path=\\server\share; User Name=USERNAME; Password=PASSWORD";
//---------------------------------------
//Setting a physical location via a PhysicalLocation instance, to connect as the Web Server authenticated identity:
//For example, when you disable `Anonymous Authentication` and
//enable one of these authentication types for a web app in IIS:
//- `Windows Authentication (NTLM)`
//- `Digest Authentication (Negotiate)`
//- `Basic Authentication`
//Then IIS can pass the already authenticated user info to the web app.
//This user can then be impersonated by the web app when necessary, e.g. when accessing files.
location = new PhysicalLocation
{
Path = @"\\server\share", //a UNC path or a local path
AuthenticatedUser = AuthenticatedUser.WebServer
};
//Setting a physical location via a provider string, to connect as the Web Server authenticated identity:
location = @"Path=\\server\share; Authenticated User=WebServer";
//---------------------------------------
//Setting a physical location via a PhysicalLocation instance, to connect as the Claims UPN identity:
//App's identities in `Thread.CurrentPrincipal` will be searched for a UPN (User Principal Name) claim.
//If any UPN is found, it will be authenticated via S4U Kerberos.
//This user can then be impersonated by the web app when necessary, e.g. when accessing files.
location = new PhysicalLocation
{
Path = @"\\server\share", //a UNC path or a local path
AuthenticatedUser = AuthenticatedUser.ClaimsUpn
};
//Setting a physical location via a provider string, to connect as the Claims UPN identity:
location = @"Path=\\server\share; Authenticated User=ClaimsUpn";
Dim location As Location
'Setting a physical location via a PhysicalLocation instance:
'Path can also be virtual path string like "~/App_Data/SomeFolder" in a web application.
location = New PhysicalLocation() With {
.Path = "c:\SomeFolder"
}
'Setting a physical location via a provider string (same as above):
location = "Type=Physical; Path=c:\SomeFolder"
'---------------------------------------
'Setting a physical location via a PhysicalLocation instance, to connect as a specific user:
'UserName can be specified as "Domain\User", "User@Domain" (UPN format), "Machine\User", "User" (local user).
location = New PhysicalLocation() With {
.Path = "\\server\share", 'a UNC path or a local path
.UserName = "USERNAME",
.Password = "PASSWORD"
}
'Setting a physical location via a provider string, to connect as a specific user (same as above):
'In a provider string, if a value contains semi-colon character, that value should be enclosed
'in single quotes (e.g. Password='PASS;WORD') or double quotes (e.g. Password="PASS;WORD").
location = "Path=\\server\share; User Name=USERNAME; Password=PASSWORD"
'---------------------------------------
'Setting a physical location via a PhysicalLocation instance, to connect as the Web Server authenticated identity:
'For example, when you disable `Anonymous Authentication` And
'enable one of these authentication types for a web app in IIS:
'- `Windows Authentication (NTLM)`
'- `Digest Authentication (Negotiate)`
'- `Basic Authentication`
'Then IIS can pass the already authenticated user info to the web app.
'This user can then be impersonated by the web app when necessary, e.g. when accessing files.
location = New PhysicalLocation() With {
.Path = "\\server\share", 'a UNC path or a local path
.AuthenticatedUser = AuthenticatedUser.WebServer
}
'Setting a physical location via a provider string, to connect as the Web Server authenticated identity:
location = "Path=\\server\share; Authenticated User=WebServer"
'---------------------------------------
'Setting a physical location via a PhysicalLocation instance, to connect as the Claims UPN identity:
'App's identities in `Thread.CurrentPrincipal` will be searched for a UPN (User Principal Name) claim.
'If any UPN Is found, it will be authenticated via S4U Kerberos.
'This user can then be impersonated by the web app when necessary, e.g. when accessing files.
location = New PhysicalLocation() With {
.Path = "\\server\share", 'a UNC path or a local path
.AuthenticatedUser = AuthenticatedUser.ClaimsUpn
}
'Setting a physical location via a provider string, to connect as the Claims UPN identity:
location = "Path=\\server\share; Authenticated User=ClaimsUpn"
Setting an Azure Blob location:
Location location;
//Setting an Azure Blob location via an AzureBlobLocation instance:
location = new AzureBlobLocation
{
//Leave Path empty to connect to the root of the container.
//For connecting to subfolders, Path should be specified as a relative path (e.g. "some/folder")
//Path = "some/folder",
//Get these values from your Azure Portal (Storage Account -> Access Keys -> Connection String)
Container = "CONTAINER",
AccountName = "XXX",
AccountKey = "XXX"
};
//Setting an Azure Blob location via a provider string (same as above):
//In a provider string, if a value contains semi-colon character, that value should be enclosed
//in single quotes (e.g. Password='PASS;WORD') or double quotes (e.g. Password="PASS;WORD").
location = "Type=AzureBlob; Container=CONTAINER; Account Name=XXX; Account Key=XXX";
Dim location As Location
'Setting an Azure Blob location via an AzureBlobLocation instance:
'Leave Path empty to connect to the root of the container.
'For connecting to subfolders, Path should be specified as a relative path (e.g. "some/folder")
'Path = "some/folder",
'Get these values from your Azure Portal (Storage Account -> Access Keys -> Connection String)
location = New AzureBlobLocation() With {
.Container = "CONTAINER",
.AccountName = "XXX",
.AccountKey = "XXX"
}
'Setting an Azure Blob location via a provider string (same as above):
'In a provider string, if a value contains semi-colon character, that value should be enclosed
'in single quotes (e.g. Password='PASS;WORD') or double quotes (e.g. Password="PASS;WORD").
location = "Type=AzureBlob; Container=CONTAINER; Account Name=XXX; Account Key=XXX"
Setting an Amazon S3 location:
Location location;
//Setting an Amazon S3 location via an AmazonS3Location instance:
location = new AmazonS3Location
{
//Leave Path empty to connect to the root of the bucket.
//For connecting to subfolders, Path should be specified as a relative path (e.g. "some/folder")
//Path = "some/folder",
BucketName = "BUCKET",
Region = "eu-central-1",
AccessKeyId = "XXX",
SecretAccessKey = "XXX",
};
//Setting an Amazon S3 location via a provider string (same as above):
//In a provider string, if a value contains semi-colon character, that value should be enclosed
//in single quotes (e.g. Password='PASS;WORD') or double quotes (e.g. Password="PASS;WORD").
location = "Type=AmazonS3; Bucket Name=BUCKET; Region=eu-central-1; Access Key Id=XXX; Secret Access Key=XXX";
Dim location As Location
'Setting an Amazon S3 location via an AmazonS3Location instance:
'Leave Path empty to connect to the root of the bucket.
'For connecting to subfolders, Path should be specified as a relative path (e.g. "some/folder")
'Path = "some/folder",
location = New AmazonS3Location() With {
.BucketName = "BUCKET",
.Region = "eu-central-1",
.AccessKeyId = "XXX",
.SecretAccessKey = "XXX"
}
'Setting an Amazon S3 location via a provider string (same as above):
'In a provider string, if a value contains semi-colon character, that value should be enclosed
'in single quotes (e.g. Password='PASS;WORD') or double quotes (e.g. Password="PASS;WORD").
location = "Type=AmazonS3; Bucket Name=BUCKET; Region=eu-central-1; Access Key Id=XXX; Secret Access Key=XXX"