Set externally uploaded file field through API

Options

Hello! How can I set externally uploaded file field through API? This is what I managed to get, but the main problem is that "url" is prefixed with XANO domain

{
  "path": "https://cdn-api-dev.jetadmin.app/media/static_files/projects/test_1251/slideout_TBlx6gL.svg",
  "name": "slideout_TBlx6gL.svg",
  "type": "image",
  "size": 0,
  "mime": "image/svg+xml",
  "meta": {},
  "url": "https://x8ki-letl-twmt.n7.xano.iohttps://cdn-api-dev.jetadmin.app/media/static_files/projects/test_1251/slideout_TBlx6gL.svg"
}


Tagged:

Answers

  • Michael Udinski
    Michael Udinski Administrator

    ADMIN

    Options

    Hi @d.kildishev - I'd love if you can elaborate with more context into your use-case. I might be able to provide more guidance. But for a quick fix, you can use the trim filter to trim your Xano domain of the URL.

  • d.kildishev
    Options

    So the main case is that I want to set "attachment" with URL which is not hosted on Xano, but whatever I tried - it always prefixes "url" field with "https://x8ki-letl-twmt.n7.xano.io".

    We have an integration with your product where users connect Xano, but have files uploaded not on Xano and they need to save such files to Xano API. So we can't modify our users endpoints to trim domain of the URL.

  • Michael Udinski
    Michael Udinski Administrator

    ADMIN

    Options

    Can you please show how you're creating the image in the function stack? I'm a little confused why your URL would be like so. Are you providing a value for the filename in the Create Image Metadata function?

  • d.kildishev
    Options

    I'm using default Application table from Templates and I have image which is externally uploaded. I want to set this image to database without uploading it again.

  • Michael Udinski
    Michael Udinski Administrator

    ADMIN

    Options

    @d.kildishev - I wouldn't use the image data type in that case. Since you already have the attachemnt URL, I'd just store the attachment URL as a text field in Xano. The attachment/image/video/audio data types are designed to be used with Xano's media uploader - which is why you have your Xano domain added to the existing URL. If you want to store additional metadata then you can do that separately.