Rackspace cloud file c#, adding files to directory
Adding files to a specific directory using rackspace cloud files, c# bindings api more specifically reference: https://github.com/rackspace/csharp-cloudfiles
For some strange reason doing something like:
public static void UploadFile(CSImageDTO file)
{
var connection = new Connection(UserCredentials);
var containerItemList = connection.GetContainerItemList(ContainerName);
if (!containerItemList.Contains(f开发者_开发问答ile.Filename))
connection.PutStorageItem(ContainerName, file.File, Path.Combine(MyPath, Path.GetFileName(file.Filename)));
else
throw new NotSupportedException("we dont know what to do now...");
}
Presuming MyPath = "Funky";
This adds files like so:
- Funky/Image1.jpg
- Funky/Image5.png
- ...
I could get the file path using Path.GetFileName(filepath)
and return that to the view, but I want to know my files are not stored under the directory "Funky", instead the actual file name is called "Funky/Image1.png"
? or so it appears using my code:
public static IEnumerable<string> GetFiles()
{
var connection = new Connection(UserCredentials);
var parameters = new Dictionary<GetItemListParameters, string>();
//parameters.Add(GetItemListParameters.Path, MyPath);
var containerItemList = connection.GetContainerItemList(ContainerName, parameters)
.Where(x => Path.HasExtension(x));
//.Select(x => Path.GetFileName(x));
return containerItemList;
}
Also note: I have to use this filter to make sure I dont get the file folder back...
.Where(x => Path.HasExtension(x));
Because it is a Flat file system...
精彩评论