0

I'm using a raw post since I'm using react native and I didn't see a react-native library.

I'm getting a 403 response when trying to upload using the raw upload form post- is there a setting that I need to set or is my public key not activated or something? I don't see a text response in the 403 response so not sure what the specific error is.

Here's my sample CURL from postman

curl -X POST -H "Content-Type: multipart/form-data; boundary=..." 
-F "UPLOADCARE_PUB_KEY=foo" 
-F "UPLOADCARE_STORE=1" 
-F "file=@logo.jpg" "https://upload.uploadcare.com/base/"
MonkeyBonkey
  • 46,433
  • 78
  • 254
  • 460

2 Answers2

0

I see you are trying to use multipart upload, how big is logo.jpg? Are you able to upload the same file using the dashboard?

Omar Khazamov
  • 147
  • 1
  • 8
  • It was a small file, just 47kb – MonkeyBonkey Mar 21 '17 at 11:17
  • Can you try setting your public key to 'demopublickey' and see what the response looks like? `curl -X POST -H "Content-Type: multipart/form-data; boundary=..." -F "UPLOADCARE_PUB_KEY=demopublickey" -F "UPLOADCARE_STORE=1" -F "file=@logo.jpg" "https://upload.uploadcare.com/base/"` – Omar Khazamov Mar 22 '17 at 13:13
  • still getting a 403 `curl -X POST -H "Content-Type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW" -F "UPLOADCARE_PUB_KEY=demopublickey" -F "UPLOADCARE_STORE=1" -F "file=@test.jpg" "https://upload.uploadcare.com/base/"` – MonkeyBonkey Mar 22 '17 at 14:06
  • Ok, I found the issue with postman - it was adding a content-type appliction/json in the console that wasn't showing up in the curl export. It seems to work now. – MonkeyBonkey Mar 22 '17 at 22:18
0

Here are few things you should look at:

  1. content-type is not needed here
  2. reason for 4xx should be stated in response body or headers
  3. make sure that you don't have typos in API key
  4. make sure that automatic storing is enabled in the project or send "UPLOADCARE_STORE=auto"
  5. make sure that your account is not blocked, has some quota left, file type is allowed, etc.
  6. don't rely on Postman, check the command with cURL

This works:

curl -vv -X POST \ -F "UPLOADCARE_PUB_KEY=demopublickey" \ -F "UPLOADCARE_STORE=1" \ -F "file=@logo.png" "https://upload.uploadcare.com/

Dmitry Mukhin
  • 6,649
  • 3
  • 29
  • 31
  • It looks like it was an issue with Postman adding a content-type of application/json in the header maybe - seems to work now – MonkeyBonkey Mar 23 '17 at 11:16