Code Monkey home page Code Monkey logo

songhay.cloud.blobstorage's People

Contributors

bryanwilhite avatar

Watchers

 avatar  avatar  avatar

songhay.cloud.blobstorage's Issues

consider adding filtering support to `ListBlobsAsync`

here is a sketch:

internal async Task<IEnumerable<string>> GetYouTubeChannelBlobsAsync(string blobContainerChannelsPath, Func<IListBlobItem, bool> filter)
{
    this.CheckProgramMetadata();

    traceSource?.WriteLine($"{nameof(GetYouTubeChannelBlobsAsync)} getting channel BLOBs...");

    if (filter == null) filter = i => true;

    var blobs = await this._container
        .ListBlobsAsync(useFlatBlobListing: true, pageLimit: 5, rootPath: blobContainerChannelsPath);

    var tasks = blobs.Where(filter).Select(i => (i as ICloudBlob).ToStringFromBlobAsync());

    await Task.WhenAll(tasks);

    traceSource?.WriteLine($"{nameof(GetYouTubeChannelBlobsAsync)} downloaded {tasks.Count()} BLOBs.");

    return tasks.Select(i => i.Result);
}

`Listing snapshots is only supported in flat mode` issue requires change to API

this error will be thrown:

System.ArgumentException: 'Listing snapshots is only supported in flat mode (no delimiter). Consider setting the useFlatBlobListing parameter to true.
Parameter name: blobListingDetails'

when this API call is made:

var blobs = await this._container.ListBlobsAsync(useFlatBlobListing: false, pageLimit: 5, rootPath: blobContainerChannelsPath);

consider adding/reviewing `JObject` support

extensions based on these might be helpful:

internal async Task<JObject> DownloadBlobAsync(string blobName)
{
    var blob = this._container.GetBlockBlobReference(blobName);
    var json = await blob.ToStringFromBlobAsync();
    return JObject.Parse(json);
}

internal async Task UploadBlobAsync(JObject jObject, string blobName)
{
    var blob = this._container.GetBlockBlobReference(blobName);
    blob.Properties.ContentType = MimeTypes.ApplicationJson;
    traceSource?.TraceVerbose($"Uploading {blobName}...");
    await blob.UploadTextAsync(jObject.ToString());
}

add ConfigurationBuilder extension methods for CloudStorageAccount

take learnings from Songhay.Blog and centralize:

public static CloudStorageAccount ToCloudStorageAccount(this ConfigurationBuilder builder, string basePath, string connectionStringName)
{
    if (builder == null) throw new NullReferenceException("The expected Configuration builder is not here.");
    if (!Directory.Exists(basePath)) throw new DirectoryNotFoundException("The expected configuration base path is not here.");

    builder
        .SetBasePath(basePath)
        .AddJsonFile(AppScalars.conventionalSettingsFile, optional: false, reloadOnChange: true);

    var meta = new ProgramMetadata();
    builder.Build().Bind(nameof(ProgramMetadata), meta);

    if (meta.CloudStorageSet == null) throw new NullReferenceException("The expected cloud storage set is not here.");

    var key = AppScalars.cloudStorageSetName;
    var test = meta.CloudStorageSet.TryGetValue(key, out var set);
    if (!test) throw new NullReferenceException($"The expected cloud storage set, {key}, is not here.");
    if (!set.Any()) throw new NullReferenceException($"The expected cloud storage set items for {key} are not here.");

    test = set.TryGetValue(connectionStringName, out var connectionString);
    if (!test) throw new NullReferenceException($"The expected cloud storage set connection, {connectionStringName}, is not here.");

    var cloudStorageAccount = CloudStorageAccount.Parse(connectionString);
    return cloudStorageAccount;
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.