bldrs-ai / Share

Share is a web-based BIM & CAD collaboration platform.
http://bldrs.ai
105 stars 31 forks source link

Notes 100: Images Not Loading for Private Models #1246

Open OlegMoshkovich opened 3 months ago

OlegMoshkovich commented 3 months ago

When accessing notes that contain images for private models, the images fail to load and result in a 404 error.

Steps to Reproduce:

Expected Behavior: The images should load correctly and be displayed within the note.

Actual Behavior: Images do not load and instead a 404 error is received.

Screenshot of the Network tab:

image
OlegMoshkovich commented 3 months ago

ChatGPT answer:

If you are authenticated and still experiencing 404 errors when trying to fetch and display an image from a private repository in a GitHub issue, the issue may be related to how GitHub handles attachments for private repositories. Here are some steps you can take to troubleshoot and potentially resolve this issue:

Steps to Troubleshoot and Resolve

  1. Verify URL Format: Ensure that the URL is correctly formatted and points to the correct resource. The example URL you provided looks like an attachment URL rather than a direct link to a file in the repository.

  2. Check Access Permissions: Verify that you have the necessary permissions to access the private repository and the specific issue where the attachment is located.

  3. Direct Link to Image: Sometimes, the way images are linked in issues can cause problems. Ensure you are using the correct format to link the image. For example:

    ![Image Description](https://github.com/user-attachments/assets/47cfeeac-6263-420a-82c3-a2cd898069b3)
  4. Session Validity: Make sure your session has not expired. Re-authenticate if necessary and try accessing the image URL again.

  5. Use GitHub API for Authenticated Access: If you need to programmatically access the image, use the GitHub API with authentication headers. Here’s an example in Python:

    import requests
    
    url = 'https://github.com/user-attachments/assets/47cfeeac-6263-420a-82c3-a2cd898069b3'
    headers = {'Authorization': 'token YOUR_ACCESS_TOKEN'}
    response = requests.get(url, headers=headers)
    
    if response.status_code == 200:
       with open('image.png', 'wb') as f:
           f.write(response.content)
       print('Image downloaded successfully')
    else:
       print('Failed to fetch image:', response.status_code)
  6. Embed Images in README or Wiki: If the image is for documentation purposes, consider uploading the image directly to the repository (e.g., in a docs folder) and linking to it from the README or Wiki. This method can help avoid issues with attachments.

Additional Considerations

Example of Linking Images Properly in Markdown

![Example Image](https://github.com/username/repository/raw/main/path/to/image.png)

Replace username, repository, main, and path/to/image.png with the appropriate values.

By following these steps and considerations, you should be able to troubleshoot and resolve the issue of images returning 404 errors in GitHub issues for private repositories. If the problem persists, reaching out to GitHub Support may provide further assistance.