Skip to content

How to upload image using rest api? #369

Answered by pranavxc
pranavxc asked this question in Q&A
Discussion options

You must be logged in to vote

It can be done in two steps

  1. Upload the image using our meta API which returns the public URL and other meta details.

    Example in Javascript(with Axios)

    const formData = new FormData();
    formData.append("file", yourFile);
    formData.append('json', JSON.stringify({"api":"xcAttachmentUpload","project_id":"global_vL7d","dbAlias":"db","args":{}}));
    
    axios({
      url: '<your public url>/dashboard',
      data: formData, 
      headers:{ 
          'Content-Type': 'multipart/form-data',
          "xc-auth": "<auth_token>"
      },
      method: 'post',
      params: {"project_id":"global_vL7d"},
    })).then(res => {
          console.log(res)
    
          //  insert/update  record
    })

    Response will be:

    {"url":"http://localhost:8080/dl/ben_qu…

Replies: 13 comments 9 replies

Comment options

pranavxc
Jul 22, 2021
Maintainer Author

You must be logged in to vote
2 replies
@asutpshnik
Comment options

@derawi
Comment options

Answer selected by pranavxc
Comment options

You must be logged in to vote
1 reply
@o1lab
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

pranavxc
Dec 2, 2021
Maintainer Author

You must be logged in to vote
3 replies
@gustavohwulee
Comment options

@o1lab
Comment options

@wingkwong
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@mihazg99
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@asutpshnik
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@wingkwong
Comment options

Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet