{"id":28387317,"url":"https://github.com/digitalruby/s3objectstore","last_synced_at":"2025-06-26T19:32:39.584Z","repository":{"id":47327724,"uuid":"508005619","full_name":"DigitalRuby/S3ObjectStore","owner":"DigitalRuby","description":"Allow storing json objects in S3 easily","archived":false,"fork":false,"pushed_at":"2024-03-24T01:25:18.000Z","size":89,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-05-30T22:47:41.956Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/DigitalRuby.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2022-06-27T17:39:27.000Z","updated_at":"2022-06-28T00:36:06.000Z","dependencies_parsed_at":"2024-03-22T22:49:49.203Z","dependency_job_id":null,"html_url":"https://github.com/DigitalRuby/S3ObjectStore","commit_stats":{"total_commits":15,"total_committers":1,"mean_commits":15.0,"dds":0.0,"last_synced_commit":"dd09148c89f4bdc8bf8583d1a0d2f6ced7e47f6c"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/DigitalRuby/S3ObjectStore","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DigitalRuby%2FS3ObjectStore","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DigitalRuby%2FS3ObjectStore/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DigitalRuby%2FS3ObjectStore/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DigitalRuby%2FS3ObjectStore/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/DigitalRuby","download_url":"https://codeload.github.com/DigitalRuby/S3ObjectStore/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DigitalRuby%2FS3ObjectStore/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262132607,"owners_count":23264026,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-05-30T17:11:04.699Z","updated_at":"2025-06-26T19:32:39.542Z","avatar_url":"https://github.com/DigitalRuby.png","language":"C#","readme":"# S3 Object Store\n\n## Allow storing json objects in S3 easily\n\nGoals:\n- Map objects to a sensible s3 hierarchy\n- Use json for fast-ish and flexible serialization and model updates + human readability\n- Control the folder template name with options\n\nPlease see the Sandbox project, `Program.cs` which shows a simple example of using sessions.\n\n### Usage\n\n#### Define an object that implements the `IStorageObject` interface:\n\n```cs\n/// \u003csummary\u003e\n/// Example session object\n/// \u003c/summary\u003e\npublic sealed class Session : IStorageObject\n{\n    /// \u003csummary\u003e\n    /// The session identifier, probably a guid\n    /// \u003c/summary\u003e\n    [JsonPropertyName(\"k\")]\n    public string? Key { get; set; } = string.Empty;\n\n    /// \u003csummary\u003e\n    /// The account id the session belongs to, probably a guid. Can be null if no owner.\n    /// \u003c/summary\u003e\n    [JsonPropertyName(\"o\")]\n    public string? Owner { get; set; }\n\n    /// \u003csummary\u003e\n    /// IP address\n    /// \u003c/summary\u003e\n    [JsonPropertyName(\"i\")]\n    public string IPAddress { get; set; } = string.Empty;\n\n    /// \u003csummary\u003e\n    /// User agent\n    /// \u003c/summary\u003e\n    [JsonPropertyName(\"a\")]\n    public string UserAgent { get; set; } = string.Empty;\n\n    /// \u003csummary\u003e\n    /// When the session expires\n    /// \u003c/summary\u003e\n    [JsonPropertyName(\"e\")]\n    public DateTimeOffset Expires { get; set; }\n\n    /// \u003csummary\u003e\n    /// Could put permissions for the session here\n    /// \u003c/summary\u003e\n    [JsonPropertyName(\"p\")]\n    public string Permissions { get; set; } = string.Empty;\n\n    /// \u003cinheritdoc /\u003e\n    public override string ToString()\n    {\n        return $\"{Key} {Owner} {IPAddress} {UserAgent} {Expires} {Permissions}\";\n    }\n}\n```\n\nUsing `JsonPropertyName` to shorten property names is highly recommended as it will save you on storage space.\n\nThe `IStorageObject` interface will return null for both `Key` and `Owner` by default.\n\nIn most cases, you will usually implement both the `Key` and `Owner` properties yourself and return `Guid` or some other identifier.\n\nExceptions to this case:\n- You can return null for the `Owner` if your service options (see down below) do not have a format specifier for the owner in the folder template - `{0}`.\n- You can return null for the `Key` if your service options specify that the folder format has the file name in it. By default, the `Key` is used as the file name, with a `.json` extension.\n\n#### Create your s3 repository\n\n```cs\n// note disable signing is required for cloudflare r2\n// set disable signing to false as long as your s3 provider works\nvar config = new S3Config(accessKey, secretKey, url, disableSigning);\n\n// in production, deleting and creating buckets is not allowed for safety\n// you can get both the environment and logger from `IServiceProvider` when using a full .net 6 app.\nvar repository = new S3StorageRepository(config, new FakeEnvironment(), new NullLogger\u003cS3StorageRepository\u003e());\n```\n\n#### Create your object service\n\n```cs\nvar serviceOptions = new StorageObjectServiceOptions\u003cSession\u003e\n{\n    Bucket = \"bucketname\",\n\n    // the folder format does not need a {0} if there is no owner for the object (owner is null)\n    // by default the key will be appended to this folder with a .json extension\n    FolderFormat = \"users/{0}/sessions\",\n\n    // if your folder format contains the file name, for example to store a user profile, you could use:\n    // users/{0}/profile.json, which would ignore the key as part of the file name\n    FolderFormatIncludesFileName = false\n};\n\n// create s3 object service, wrapping the s3 repository\nvar service = new S3StorageObjectService\u003cSession\u003e(serviceOptions, repository);\n```\n\n#### Perform operations\n\nThe storage object service interface is as follows:\n\n```cs\n/// \u003csummary\u003e\n/// Storage object service interface. Stores one or more objects (like sessions) with an owner (like a user).\n/// \u003c/summary\u003e\n/// \u003ctypeparam name=\"T\"\u003eTypes of objects to work with, must be json serializable\u003c/typeparam\u003e\npublic interface IStorageObjectService\u003cT\u003e where T : class, IStorageObject\n{\n    /// \u003csummary\u003e\n    /// Get an object by key and owner\n    /// \u003c/summary\u003e\n    /// \u003cparam name=\"key\"\u003eKey\u003c/param\u003e\n    /// \u003cparam name=\"owner\"\u003eOwner identifier\u003c/param\u003e\n    /// \u003creturns\u003eObject or null if not found\u003c/returns\u003e\n    Task\u003cT?\u003e GetObjectAsync(string key, string owner);\n\n    /// \u003csummary\u003e\n    /// Set an object. The key and owner properties are used to determine the folder path\n    /// \u003c/summary\u003e\n    /// \u003cparam name=\"obj\"\u003eObject\u003c/param\u003e\n    /// \u003creturns\u003eTask\u003c/returns\u003e\n    Task SetObjectAsync(T obj);\n\n    /// \u003csummary\u003e\n    /// Get all objects for the owner.\n    /// \u003c/summary\u003e\n    /// \u003cparam name=\"owner\"\u003eOwner identifier\u003c/param\u003e\n    /// \u003creturns\u003eTask of found objects\u003c/returns\u003e\n    Task\u003cIReadOnlyCollection\u003cT\u003e\u003e GetObjectsAsync(string owner);\n\n    /// \u003csummary\u003e\n    /// Get just the keys for the owner, much more lightweight operation\n    /// \u003c/summary\u003e\n    /// \u003cparam name=\"owner\"\u003eOwner\u003c/param\u003e\n    /// \u003creturns\u003eTask of keys\u003c/returns\u003e\n    Task\u003cIReadOnlyCollection\u003cstring\u003e\u003e GetKeys(string owner);\n\n    /// \u003csummary\u003e\n    /// Delete object.\n    /// \u003c/summary\u003e\n    /// \u003cparam name=\"key\"\u003eKey\u003c/param\u003e\n    /// \u003cparam name=\"owner\"\u003eOwner identifier\u003c/param\u003e\n    /// \u003creturns\u003eTask\u003c/returns\u003e\n    Task DeleteObjectAsync(string key, string owner);\n}\n```\n\nPlease email support@digitalruby.com if you have questions or feedback.\n\n-- Jeff\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdigitalruby%2Fs3objectstore","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdigitalruby%2Fs3objectstore","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdigitalruby%2Fs3objectstore/lists"}