V
V
Vladislav Verbitsky2022-02-23 14:14:03
JavaScript
Vladislav Verbitsky, 2022-02-23 14:14:03

Why is the Tatum API not accepting a request to create a file?

<head>


<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js" integrity="sha512-894YE6QWD5I59HgZOGReFYm4dnWc1Qt5NtvYSaNcOP+u1T9qYdvdihz0PPSiiqn/+/3e7Jo4EaG7TubfWGUrMQ==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>

    </head>
    <body>
        <form action="" id="myform">
            <input type="file" name="image">
            <button type="submit">Отправить</button>
        </form>

$(document).ready(function() {
  $('form#myform').submit(function(e) {
     e.preventDefault();
     var formData = new FormData(this);
     const settings = {
        async: true,
        data: formData,
        crossDomain: true,
        url: "https://api-us-west1.tatum.io/v3/ipfs",
        method: "POST",
        cache:false,
        contentType: false,
        processData: false,        
        headers: {          
          "x-api-key": "20a81c01-7c50-46f5-9355-1a3a74d6c271"
        }
     }; 
     $.ajax(settings).done(function (response) {
         console.log(response);
     });
   });
});


There is this code: the user inserts a file that is sent via api and IPFS is made from it, but Google gives an error 621616b6baa0e333934291.jpeg
I was told that the problem is in the server, but how to solve it? What to do, how to change the program to run on a live server VS Code? Tell me please!!! In general, everything is taken from this documentation, if it is easier, then you can modify it, there will be no difference. It is necessary that in the end the user loads the image, and at the output receives an IPFS link. This api request is used for this. I also specified the api key in the code, here it is: "20a81c01-7c50-46f5-9355-1a3a74d6c271", it is free for tests, so there is no sense in it.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Immortal_pony, 2022-02-23
@VladisLove2525

First
Your field is called "image" And in the documentation it is written in English and white that it should be called file Second: The documentation says that it is mandatory to specify header content-type:multipart/form-data, which you don't do. They even wrote the code for you in the documentation already: PS And what is Google doing here anyway?
<input type="file" name="image">

62169929b9bf9356824846.png

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question