Skip to content

Send Images through HTTPS Authorization #657

Closed Answered by vivekatoffice
marsmith asked this question in General
Discussion options

You must be logged in to vote

With saving image on the local drive using the Filename from "Content-Disposition"*

from fastapi import FastAPI, HTTPException, Depends, Request
from fastapi.security import HTTPBasic, HTTPBasicCredentials
from fastapi.responses import JSONResponse
from starlette.status import HTTP_401_UNAUTHORIZED
import os
from PIL import Image
import time
from email.header import decode_header
import re

app = FastAPI()

security = HTTPBasic()

# Hardcoded credentials
USER_DATA = {
    "root": "pass"
}

UPLOAD_FOLDER = 'uploads'
os.makedirs(UPLOAD_FOLDER, exist_ok=True)

def get_current_username(credentials: HTTPBasicCredentials = Depends(security)):    
    correct_username = credentials.username in U…

Replies: 4 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@vivekatoffice
Comment options

Answer selected by vivekatoffice
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants