You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Retrieving images URL through a jinja template from a view context, involves calling the file URL of the saved image. Anytime we try to get the images from the media server of Zubhub on local development we get a Connection Error.
Here is the code:
# The view codedefget(self, request, *args, **kwargs):
activity=self.get_object()
activity_images=ActivityImage.objects.filter(activity=activity)
activity_steps=ActivityMakingStep.objects.filter(activity=activity)
ifsettings.ENVIRONMENT=='production':
qr_code=generate_qr_code(
link=f"https://zubhub.unstructured.studio/activities/{activity.id}"
)
else:
qr_code=generate_qr_code(
link=f"{settings.DEFAULT_BACKEND_PROTOCOL}//{settings.DEFAULT_BACKEND_DOMAIN}/activities/{activity.id}"
)
context= {
'activity': activity,
'activity_id': activity.id,
'activity_images': activity_images,
'activity_steps': activity_steps,
'activity_steps_images': [step.image.all() forstepinactivity_steps],
'activity_category': [category.nameforcategoryinactivity.category.all()],
'creators': [creatorforcreatorinactivity.creators.all()],
'qr_code': qr_code
}
returngenerate_pdf(
template_path=self.template_path,
context=context
)
# The util functiondefdownload_file(file_url):
""" Download a file from a given URL and save it to the local filesystem. Args: file_url (str): The URL of the file to download. Returns: bytes: The file data. """response=requests.get(file_url, stream=True)
response.raise_for_status()
file_data=b""forchunkinresponse.iter_content(chunk_size=4096):
ifchunk:
file_data+=chunkreturnfile_data
The Behavior
To Reproduce
Import the ActivityImage Model
Build a view logic that relies on a Jinja template.
Setup the context to be used in the template
Try calling an image from the media server into the template
The Connection Error
Expected behavior
Under normal circumstances we were to get the image from the media server
Notes
This behavior does not happen when we call images from the media server in production.
The text was updated successfully, but these errors were encountered:
Hello @yokwejuste , your description of the issue is a bit vague. Can you give a more detailed explanation and issue reproduction steps? if possible make a video?
It'd be helpful to know EXACTLY what you are trying to do.
Hello @yokwejuste , your description of the issue is a bit vague. Can you give a more detailed explanation and issue reproduction steps? if possible make a video? It'd be helpful to know EXACTLY what you are trying to do.
Description
Retrieving images URL through a jinja template from a view context, involves calling the file URL of the saved image. Anytime we try to get the images from the media server of Zubhub on local development we get a
Connection Error
.Here is the code:
The Behavior
To Reproduce
Connection Error
Expected behavior
Under normal circumstances we were to get the image from the media server
Notes
The text was updated successfully, but these errors were encountered: