简体   繁体   中英

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(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));

Because it is a Flat file system...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM