Roblox now just returns the asset id
This commit is contained in:
parent
3574e3d70d
commit
d84bfb7eba
21
asset.go
21
asset.go
@ -1,9 +1,9 @@
|
|||||||
package roblox
|
package roblox
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
|
"io/ioutil"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
"strconv"
|
"strconv"
|
||||||
@ -24,12 +24,10 @@ type AssetUploadResponse struct {
|
|||||||
AssetVersionID int64 `json:"AssetVersionId"`
|
AssetVersionID int64 `json:"AssetVersionId"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Session) CreateAsset(options *AssetUploadOptions, f io.Reader) (AssetUploadResponse, error) {
|
func (s *Session) CreateAsset(options *AssetUploadOptions, f io.Reader) (int, error) {
|
||||||
var aresp AssetUploadResponse
|
|
||||||
|
|
||||||
endpoint, err := url.Parse("https://data.roblox.com/Data/Upload.ashx?json=1&type=Model&genreTypeId=1")
|
endpoint, err := url.Parse("https://data.roblox.com/Data/Upload.ashx?json=1&type=Model&genreTypeId=1")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return aresp, err
|
return -1, err
|
||||||
}
|
}
|
||||||
|
|
||||||
query := endpoint.Query()
|
query := endpoint.Query()
|
||||||
@ -64,7 +62,7 @@ func (s *Session) CreateAsset(options *AssetUploadOptions, f io.Reader) (AssetUp
|
|||||||
// Perform request
|
// Perform request
|
||||||
resp, err := s.client.Do(req)
|
resp, err := s.client.Do(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return aresp, err
|
return -1, err
|
||||||
}
|
}
|
||||||
defer resp.Body.Close()
|
defer resp.Body.Close()
|
||||||
|
|
||||||
@ -75,20 +73,21 @@ func (s *Session) CreateAsset(options *AssetUploadOptions, f io.Reader) (AssetUp
|
|||||||
// Perform request
|
// Perform request
|
||||||
resp, err = s.client.Do(req)
|
resp, err = s.client.Do(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return aresp, err
|
return -1, err
|
||||||
}
|
}
|
||||||
defer resp.Body.Close()
|
defer resp.Body.Close()
|
||||||
}
|
}
|
||||||
|
|
||||||
if resp.StatusCode != 200 {
|
if resp.StatusCode != 200 {
|
||||||
return aresp, fmt.Errorf(resp.Status)
|
return -1, fmt.Errorf(resp.Status)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := json.NewDecoder(resp.Body).Decode(&aresp); err != nil {
|
body, err := ioutil.ReadAll(resp.Body)
|
||||||
return aresp, err
|
if err != nil {
|
||||||
|
return -1, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return aresp, nil
|
return strconv.Atoi(string(body))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Session) Download(id int) (io.Reader, error) {
|
func (s *Session) Download(id int) (io.Reader, error) {
|
||||||
|
Loading…
Reference in New Issue
Block a user