dollychun
(dollychun)
September 9, 2020, 9:39am
#1
What do you want to achieve?
I want to make a easy image upload plugin.
What is the issue?
I found api it can upload image, but i dont know how to use.
Is there roblox API that allows upload image from game or request? - #3 by ReturnedTrue
What solutions have you tried so far?
I’ve never seen an api that uses Formdata. I’ve tried various things, but I don’t understand how to embed config.json.
EDIT: api doc here: https://publish.roblox.com/docs#!/Items/post_v1_assets_upload
3 Likes
I have never tried this before and I do not have a fully explained solution, but unless someone else does maybe you can work it out from here:
The following post gives an example of what the request body could look like:
http, file-upload
For the image your Content-Type
of the associated file should be image/png
.
Keep in mind that, in theory, HTTP request headers and body are sent as a whole and the post linked above does not separate them. The Content-Type and Content-Length headers are important. Content-Length is simply the length of the request body without the headers .
Content-Type: multipart/form-data; boundary=----WebKitFormBoundaryePkpFF7tjBAqx29L
!!'Empty line here separates the last header and the request body'!!
------WebKitFormBoundaryePkpFF7tjBAqx29L
Also make sure to check out a previous response of mine to learn about Roblox API authentication:
https://devforum.roblox.com/t/how-can-i-make-a-group-auto-rank-script/601608/2?u=flubberlutsch
2 Likes
dollychun
(dollychun)
September 9, 2020, 11:25am
#3
I know the basics of HTTP(S). But I was able to upload one file successfully, but I can’t send two files…
I am using curl
dollychun
(dollychun)
September 9, 2020, 11:29am
#4
Log here:
#DELETED FOR SECURITY#>curl -X POST --header "Content-Type: multipart/form-data" --header "Accept: application/json" --header "Cookie: #DELETED FOR SECURITY#" --header "X-CSRF-TOKEN: #DELETED FOR SECURITY#" -F uploadAssetRequest.files1=@Apple.png -F uploadAssetRequest.files2=@config.json {\"type\":\"formData\"} "https://publish.roblox.com/v1/assets/upload" --verbose
Note: Unnecessary use of -X or --request, POST is already inferred.
* Rebuilt URL to: "type":"formData"/
* Port number ended with '"'
* Closing connection -1
curl: (3) Port number ended with '"'
Note: Unnecessary use of -X or --request, POST is already inferred.
* Trying 128.116.120.3...
* TCP_NODELAY set
* Connected to publish.roblox.com (128.116.120.3) port 443 (#0)
* schannel: SSL/TLS connection with publish.roblox.com port 443 (step 1/3)
* schannel: checking server certificate revocation
* schannel: sending initial handshake data: sending 189 bytes...
* schannel: sent initial handshake data: sent 189 bytes
* schannel: SSL/TLS connection with publish.roblox.com port 443 (step 2/3)
* schannel: failed to receive handshake, need more data
* schannel: SSL/TLS connection with publish.roblox.com port 443 (step 2/3)
* schannel: encrypted data got 4096
* schannel: encrypted data buffer: offset 4096 length 4096
* schannel: encrypted data length: 4022
* schannel: encrypted data buffer: offset 4022 length 4096
* schannel: received incomplete message, need more data
* schannel: SSL/TLS connection with publish.roblox.com port 443 (step 2/3)
* schannel: encrypted data got 415
* schannel: encrypted data buffer: offset 4437 length 5046
* schannel: sending next handshake data: sending 93 bytes...
* schannel: SSL/TLS connection with publish.roblox.com port 443 (step 2/3)
* schannel: encrypted data got 258
* schannel: encrypted data buffer: offset 258 length 5046
* schannel: SSL/TLS handshake complete
* schannel: SSL/TLS connection with publish.roblox.com port 443 (step 3/3)
* schannel: stored credential handle in session cache
> POST /v1/assets/upload HTTP/1.1
> Host: publish.roblox.com
> User-Agent: curl/7.55.1
> Accept: application/json
> Cookie: #DELETED FOR SECURITY#
> X-CSRF-TOKEN: #DELETED FOR SECURITY#
> Content-Length: 5580
> Expect: 100-continue
> Content-Type: multipart/form-data; boundary=------------------------d458e568b6a2f829
>
* schannel: client wants to read 102400 bytes
* schannel: encdata_buffer resized 103424
* schannel: encrypted data buffer: offset 0 length 103424
* schannel: encrypted data got 54
* schannel: encrypted data buffer: offset 54 length 103424
* schannel: decrypted data length: 25
* schannel: decrypted data added: 25
* schannel: decrypted data cached: offset 25 length 102400
* schannel: encrypted data buffer: offset 0 length 103424
* schannel: decrypted data buffer: offset 25 length 102400
* schannel: schannel_recv cleanup
* schannel: decrypted data returned 25
* schannel: decrypted data buffer: offset 0 length 102400
< HTTP/1.1 100 Continue
* schannel: client wants to read 102400 bytes
* schannel: encrypted data buffer: offset 0 length 103424
* schannel: encrypted data got 488
* schannel: encrypted data buffer: offset 488 length 103424
* schannel: decrypted data length: 459
* schannel: decrypted data added: 459
* schannel: decrypted data cached: offset 459 length 102400
* schannel: encrypted data buffer: offset 0 length 103424
* schannel: decrypted data buffer: offset 459 length 102400
* schannel: schannel_recv cleanup
* schannel: decrypted data returned 459
* schannel: decrypted data buffer: offset 0 length 102400
< HTTP/1.1 400 Bad Request
< cache-control: no-cache
< pragma: no-cache
< content-length: 145
< content-type: application/json
< expires: -1
< x-frame-options: SAMEORIGIN
< roblox-machine-id: CHI1-WEB2979
< p3p: CP="CAO DSP COR CURa ADMa DEVa OUR IND PHY ONL UNI COM NAV INT DEM PRE"
< date: Wed, 09 Sep 2020 11:26:37 GMT
* HTTP error before end of send, stop sending
<
{"errors":[{"code":3,"message":"The request content is missing config json file","userFacingMessage":"何らかの問題が発生しました"}]}* Closing connection 0
* schannel: shutting down SSL/TLS connection with publish.roblox.com port 443
* schannel: clear security context handle