Conditional filter when updating an image

Options
I want to allow my users to update their image profile. I'm using first_notempty filter and it works great. The only problem is when I want to update only certain fields without updating the profile image, then I'm running into an error: "Exception: missing file resource" so I guess first_notempty filter is not the right one when using input: file resource?

Any ideas? Thank you.
[Screen Shot 2022-01-28 at 11.48.19.png][Screen Shot 2022-01-28 at 11.56.37.png]

Comments

  • David Richardson
    Options
    Hey there Gavril
    I too am interested in updating a profile image,  Your message caught my eye.  Might be time to join Xano "office hours".  My model works with the WMX template that will use a Webflow user id to identify a record in a table of users.  This works across Webflow, Membersatack and Xano with identical user IDs.

    I use Uploadcare as a means to let a user upload an image.  Uploadcare generates a URL for the image that is very flexible in populating a webpage with an image balancing clarity and speed.  

    BUT, I ran into a problem I did not expect generating a API endpoint to update the user record in Xano.  Inputs are the Webflow-member-id and the "file" which is a https type URL which is text basically.  I don't have the information to debug this endpoint.  so like the Beatles said... "HELP
    [xano error 01.jpg][xano error 02.jpg]
    "
  • David Richardson
    Options
    [xano error 03.jpg]
  • David Richardson
    Options
    Gavril
    I got my issue sorted reviewing variable names and making sure spelling was consistent across the table, inputs and function stack.  In other words, user errors.  Mine.

    Hope you get yours sorted quickly.
  • Gavril Loghin
    Options
    Thanks David!
  • Gavril Loghin
    Options
     is there any chance to provide me a piece of advice regarding this? Thank you.
  • Michael Udinski
    Michael Udinski Administrator

    ADMIN

    Options
     two things here: you can't add a file recourse into your database, you need to have the image metadata formatted from your Create Image Metadata variable:
    [CleanShot 2022-01-28 at 10.58.11.png]Also, your Create Image metadata function will fail if the file resource does not have a value. You need a conditional statement to only run function if the input is empty.

     - please see the documentation and tutorial about how to upload an image:

    https://docs.xano.com/working-with-data/functions/content-upload

    You'll need to create the image metadata from a file resource input before storing to your DB
  • David Richardson
    Options
     
    Thank you for that reference.  And that might apply to many or even most online image resources.  That said I'm not all that sure how the Xano image upload function compares to Uploadcare.  My need is kind of unique.  When my users upload a file to their portfolio I have to have high DPI images to print them as a Giclée or a very high quality inkjet printing process that can produce near perfect color matching to the original - at 300 DPI.  

    Here is a Wikipedia reference https://en.wikipedia.org/wiki/Giclée
    I also need to serve the files to web pages at 72 DPI.  Uploadcare offers the ability to upload the image file once and easily crop, scale, filter, polarize etc images.  Pretty cool stuff.  In addition the uploader widget permits preset aspect ratios to user can play with to get the cropping they want.

    The original image is stored at the high DPI on an Amazon CDN server and the Uploadcare servers transform the image(s) on the fly at whatever resolution or scale or cropping you want.  They deliver to you a URLUUID (unique user id) that can transform the image appending modifiers to the URLUUID.

    I need both the 300 DPI (for printing) and 72 DPI to speed page loads without progressive loading or stratified loading of large image files.

    This work for me and with a little Webflow code ( I didn't write) displays the image on the page after it's uploaded.  For my purposes this offers the best solution for my particular needs.  I'm not throwing any shade on other solutions
  • Michael Udinski
    Michael Udinski Administrator

    ADMIN

    Options
     for your use case, I would use a dedicated image storage service like Uploadcare as you mentioned. Then just store the reference URL in the Xano DB as text. 
  • Iulian Maftei
    Options
     

    I don't know if this post is solved, but I'm running into the same problem.
    I created a simple scenario to understand better how can I fix this.

    I have a table with a user_id, image description, and the actual image.
    [Screenshot 2022-02-03 at 21.32.03.png]
    When I test my API:
    [Screenshot 2022-02-03 at 22.03.40.png]

    1. If I fill in the user_id, description, and upload an image - everything works great.
    2. If I fill in the user_id and upload an image - everything works great.
    3. If I fill in the user_id and the description - I receive an Error: Missing file resource.

    Where and what exception should I add to make the "uploading an image" step not mandatory?

    Thank you!
  • Michael Udinski
    Michael Udinski Administrator

    ADMIN

    Options
     from my above comment, you need a Conditional function. Inputs and functions behave differently because they are inherently different components.

    The Create Image from File function will throw an error if not provided a value, so you need an actual Conditional function (not a filter) to only run the function if provided a value in the file resource input.