Rackspace云文件c#,将文件添加到目录
使用rackspace云文件将文件添加到特定目录,c#绑定api更具体参考:https://github.com /rackspace/csharp-cloudfiles
由于某些奇怪的原因,做了类似的事情:
public static void UploadFile(CSImageDTO file)
{
var connection = new Connection(UserCredentials);
var containerItemList = connection.GetContainerItemList(ContainerName);
if (!containerItemList.Contains(file.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";
这会添加如下文件:
- Funky/Image1.jpg
- Funky/Image5.png
- ...
我可以使用 Path.GetFileName(filepath) 获取文件路径并将其返回到视图,但我想知道我的文件不是存储在“Funky”目录下,而是实际文件名名为“Funky/Image1.png”
?或者使用我的代码出现:
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;
}
另请注意:我必须使用此过滤器来确保我不会取回文件夹...
.Where(x => Path.HasExtension(x));
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(file.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));
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
因为它是一个平面文件系统......
Because it is a Flat file system...