{"id":19849642,"url":"https://github.com/geeks-solutions/exmedias","last_synced_at":"2025-02-28T20:44:30.792Z","repository":{"id":39972689,"uuid":"374626000","full_name":"Geeks-Solutions/exmedias","owner":"Geeks-Solutions","description":null,"archived":false,"fork":false,"pushed_at":"2025-01-10T13:03:10.000Z","size":475,"stargazers_count":0,"open_issues_count":14,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-10T14:23:29.620Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Elixir","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Geeks-Solutions.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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,"publiccode":null,"codemeta":null}},"created_at":"2021-06-07T10:31:50.000Z","updated_at":"2022-02-15T16:53:25.000Z","dependencies_parsed_at":"2024-09-06T14:29:09.195Z","dependency_job_id":"d639def7-fce3-479e-9e31-e96b49b1ec6b","html_url":"https://github.com/Geeks-Solutions/exmedias","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Geeks-Solutions%2Fexmedias","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Geeks-Solutions%2Fexmedias/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Geeks-Solutions%2Fexmedias/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Geeks-Solutions%2Fexmedias/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Geeks-Solutions","download_url":"https://codeload.github.com/Geeks-Solutions/exmedias/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241230082,"owners_count":19930919,"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":"2024-11-12T13:22:23.076Z","updated_at":"2025-02-28T20:44:30.760Z","avatar_url":"https://github.com/Geeks-Solutions.png","language":"Elixir","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Guide\n\n**Media** is a dependancy to manage, as the name implies, your media. By ``media`` we mean, your files such as documents, images, videos or podcasts.\n\n  Media stores the actual files on [S3 Amazon service](https://aws.amazon.com/s3/).\n\n## Prerequesits\n\n**Media** relies on a [thumbnex](https://github.com/talklittle/thumbnex), therefore your environment must include these two packages:\n- [ImageMagick](https://imagemagick.org/)\n- [FFmpeg](https://ffmpeg.org/)\n\n## Installation\n\n  In your mix.exs add this to your list of dependancies:\n\n  ```elixir\n  {:media, \"~\u003e 0.1.0\"}\n  ```\n\n## Configuration\n#### Common Configuration\n\nIn your `router.ex`, add this line:\n\n```elixir\nuse Media.Routes, scope: \"/media\"\n```\n\n#### PostgreSQL Based Project\n\nIf your project is connected to a ``PostgreSQL`` project then you should follow the below steps, if it is connect to ``MongoDB`` then jump to the next section.\n\nNow in your ``config.exs`` add the following:\n\n```elixir\nconfig :media,\n  otp_app: :your_app,\n  active_database: \"mongoDB\",\n  repo: :mongo,\n  content_schema: Blogs.Schema.Article,\n  content_table: \"blogs\",\n  router: YouAppWeb.Router,\n  aws_bucket_name: \"your_bucket\",\n  aws_role_name: \"you_role_to_assume_arn\",\n  aws_iam_id: \"403016165142\", ## the IAM user id\n```\n``active_database``: the database your project is using accepted values are: \"mongoDB\" or \"postgreSQL\"\n``repo``: The mongodb application name or the repo module in case it's a postgreSQL based project i.e ``YourApp.Repo``.\n``content_schema``: The content that we want to relate the medias to.\n``content_table``: Your content table name.\n`aws_role_name`: In AWS, you can create roles (`IAM` roles) that has certain permission. This role will be assumed in order to authenticate the access to private files\n`aws_iam_id`: The IAM user ID.\n\n**EXAMPLE**\n\nLet's consider having an article table. As you know, articles might contain images, videos or podcasts. This is our ``content`` schema.\n\nThe content schema must reference our media table. This is how the schema module will look like:\n\n```elixir\n  schema \"articles\" do\n  field(:title, :string)\n  field(:body, :string)\n\n  many_to_many(\n    :medias,\n    Media.PostgreSQL.Schema,\n    join_through: \"medias_contents\",\n    on_replace: :delete,\n    join_keys: [content_id: :id, media_id: :id]\n  )\n\n  timestamps()\nend\n```\nThis will imply a simple change in your changeset too:\n```elixir\n  def update_changeset(article, attrs) do\n\n  changeset =\n    article\n    |\u003e cast(attrs, [\n      :title,\n      :body\n    ])\n    |\u003e put_assoc(:medias, Map.get(attrs, :medias) || Map.get(attrs, \"medias\")) ## add this line add the end\nend\n```\n\nBefore running your project perform the following mix command:\n\n- ``mix media.setup \u0026\u0026 mix ecto.migrate``\n\nThis command will move setup your database with the latest media migrations.\n\nNow you are all set to start using Media. 🎉\n\n#### MongoDB Based Project\n```elixir\nconfig :media,\n  otp_app: :sections,\n  active_database: \"mongoDB\",\n  repo: :mongo,\n  router: SectionsWeb.Router,\n  aws_bucket_name: \"eweevtestbucketprivate\",\n  aws_role_name: \"privateBucketRead\",\n  aws_region: \"us-east-1\",\n  aws_iam_id: \"403016165142\"\n```\n``active_database``: the database your project is using accepted values are: \"mongoDB\" or \"postgreSQL\"\n``repo``: The mongodb application name or the repo module in case it's a postgreSQL based project i.e ``YourApp.Repo``.\n``content_schema``: The content that we want to relate the medias to.\n``content_table``: Your content table name.\n`aws_role_name`: In AWS, you can create roles (`IAM` roles) that has certain permission. This role will be assumed in order to authenticate the access to private files\n`aws_iam_id`: The IAM user ID.\n  In case your project relies on a ``MongoDB``, in your  ``application.ex`` file add this tuple to the children list inside the ``start`` function:\n\nIn your ``application.ex``, add the following to `children` processes that will be supervised in your `start` function:\n\n```elixir\nchildren = [\n  ...,\n  {\n  Task,\n    fn -\u003e\n      Media.Helpers.create_collections()\n    end\n  },\n  ...\n]\n```\n\nBy adding this, your collection will be setup properly adding the proper collections to your database.\n\nBefore running your project perform the following mix command:\n\n- mix media.setup\n\nNow you are all set to start using Media. 🎉","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgeeks-solutions%2Fexmedias","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgeeks-solutions%2Fexmedias","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgeeks-solutions%2Fexmedias/lists"}