skip to Main Content

this has weighed me down for a week now. seems like there’s no straight-forward solution anywhere, I’m really devastated.

I have hosted my python flask webapp and it’s postgres database successfully. Now I only need to link it with any cloud (not Google pls!) service that would enable the webapp to save images, and retrieve these images on request.
I plan to use redis for caching these images, greatly reducing the rate of requests sent to the cloud storage.
Please help!

2

Answers


  1. when you talk about save or retrieve on cloud storage what kind of storage that you have in mind? because there’s few approach:

    A. Store image / video as Binary

    Using this approach it means all uploaded file or image will be written into db and all requested file will be read from db.

    B. Store image / video as path

    Using this approach it means if its local path then it all uploaded file will stored as local file in the server where the code is hosted.

    if its remote path then it will stored on some cloud (Google Cloud Storage, AWS S3)

    Also in your question you mention about redis as cache. I want to clarify some few things about redis. In approach A if you want to reduce query sent to db you can utilize redis to store binary of frequent accessed file, so on the next request it will be fetch from cache instead from db. In approach B redis doesn’t really reduce ‘requests sent to the cloud storage’ because client still fetch the file from cloud storage and your app just return where it stored. if you want to reduce no of request sent to cloud storage then maybe you looking about client-side cache or CDN.

    Login or Signup to reply.
  2. You can save the image or video path into Redis db and retrieve them as well ,
    Here is an example of save a video path into db and load them,

    import redis
    
    
    r = redis.StrictRedis(host='localhost', port= 6379, db =0)
    video_path = "/home/user/videos/video1.mp4"
    r.set('vidpath', video_path)
    r.save
    
    getting_Video = r.get("vidpath")
    print(getting_Video) #bytes
    
    
    
    decoding_vid = getting_Video.decode('utf-8', 'ignore')
    print(decoding_vid)
    print(type(decoding_vid)) #string
    
    
    
    import cv2
    vidcap = cv2.VideoCapture(decoding_vid)
    success, image = vidcap.read()
    print(type(vidcap))
    count = 1
    while success:
      cv2.imwrite("Frames/image_%d.jpg" % count, image)    
      success, image = vidcap.read()
      print('Saved image ', count)
      count += 1
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search