Spaces:
Sleeping
Sleeping
Update pages/v4.py
Browse files- pages/v4.py +4 -3
pages/v4.py
CHANGED
|
@@ -24,9 +24,10 @@ logger = logging.getLogger(__name__)
|
|
| 24 |
# Configuration de la page Streamlit
|
| 25 |
st.set_page_config(layout="wide")
|
| 26 |
|
| 27 |
-
# Récupération des clés AWS à partir des secrets d'environnement
|
| 28 |
aws_access_key = os.environ.get("AWS_ACCESS_KEY_ID")
|
| 29 |
aws_secret_key = os.environ.get("AWS_SECRET_ACCESS_KEY")
|
|
|
|
| 30 |
|
| 31 |
# Initialisation du client S3 avec boto3
|
| 32 |
s3_client = boto3.client(
|
|
@@ -35,7 +36,7 @@ s3_client = boto3.client(
|
|
| 35 |
aws_secret_access_key=aws_secret_key,
|
| 36 |
)
|
| 37 |
|
| 38 |
-
# Fonction pour télécharger un fichier sur AWS S3
|
| 39 |
def upload_to_s3(file_path, bucket_name, object_name):
|
| 40 |
try:
|
| 41 |
s3_client.upload_file(file_path, bucket_name, object_name)
|
|
@@ -235,7 +236,7 @@ def app():
|
|
| 235 |
|
| 236 |
# Téléchargement des fichiers sur S3 et génération des liens pour chaque format généré.
|
| 237 |
for format_type, path in results.items():
|
| 238 |
-
s3_url = upload_to_s3(path,
|
| 239 |
if s3_url:
|
| 240 |
st.markdown(f"[Télécharger le timelapse {format_type}]({s3_url})", unsafe_allow_html=True)
|
| 241 |
else:
|
|
|
|
| 24 |
# Configuration de la page Streamlit
|
| 25 |
st.set_page_config(layout="wide")
|
| 26 |
|
| 27 |
+
# Récupération des clés AWS à partir des secrets d'environnement ou des variables d'environnement locales.
|
| 28 |
aws_access_key = os.environ.get("AWS_ACCESS_KEY_ID")
|
| 29 |
aws_secret_key = os.environ.get("AWS_SECRET_ACCESS_KEY")
|
| 30 |
+
bucket_name = "nom-du-bucket-s3" # Remplacez par le nom de votre bucket S3
|
| 31 |
|
| 32 |
# Initialisation du client S3 avec boto3
|
| 33 |
s3_client = boto3.client(
|
|
|
|
| 36 |
aws_secret_access_key=aws_secret_key,
|
| 37 |
)
|
| 38 |
|
| 39 |
+
# Fonction pour télécharger un fichier sur AWS S3 et retourner l'URL publique du fichier.
|
| 40 |
def upload_to_s3(file_path, bucket_name, object_name):
|
| 41 |
try:
|
| 42 |
s3_client.upload_file(file_path, bucket_name, object_name)
|
|
|
|
| 236 |
|
| 237 |
# Téléchargement des fichiers sur S3 et génération des liens pour chaque format généré.
|
| 238 |
for format_type, path in results.items():
|
| 239 |
+
s3_url = upload_to_s3(path,bucket_name , os.path.basename(path))
|
| 240 |
if s3_url:
|
| 241 |
st.markdown(f"[Télécharger le timelapse {format_type}]({s3_url})", unsafe_allow_html=True)
|
| 242 |
else:
|