Image upload service with s3

Hello guys so at my bootcamp i been tasked to do a “reusable image upload service” we currently have active storage with s3 setup with some models like an organization for example which has a picture attached to it, im supposed to upload a picture as an admin and get a link back to the picture

For now i created a module which gets the path and the name of the picture and uploads it to amazon and i get the link back, however this wouldnt work because you have to change the name of the picture and path manually. Im really lost as how to implement this so i would appreciate some guidance in the right direction

 module UploadService
  def upload
    name = 'cat5.jpg'
    s3 = 'us-east-1')
    obj = s3.bucket(ENV.fetch('AWS_BUCKET')).object(name)

AFAIK with ActiveStorage, there is no need to directly use the AWS SDK, instead you would use attach. Here is the documentation: