problem uploading binary .stl vs ascii

Discussion in 'Shapeways API' started by 225132_deleted, Aug 28, 2014.

  1. hi,

    i have trouble uploading binary .stl's over the Api,
    the file is a simple cube from rhino exported in binary and ascii. (see attached).

    The ascii seems to work;
    it keeps giving me the following error for the binary file:

    We're unable to process this file. Check your file for errors and click 'Update File' to upload a new version.
    Automatic rescale failed. Model is not within acceptable bounds in any unit. When rescaling to units in:
    - millimeter, model is 117449404946384660000000000 x 117449404946384660000000000 x 117449404946384660000000000 m
    - inch, model is 2983214830297938000000000000 x 2983214830297938000000000000 x 2983214830297938000000000000 m
    - meter, model is 117449400666740040000000000000 x 117449400666740040000000000000 x 117449400666740040000000000000 m
    Fixed Parsing problem: File size does not match the expected size for the given number of facets. Given 12 facets for a total size of 684 but the file size is 1084


    The strange thing is it does recognize the number of mesh facets (12), being a triangulated cube. So it does read something...

    the json code (checked valid) for the upload is as follows:

    {
    "isDownloadable":0,
    "file":" Umhpbm9jZXJvcyBCaW5hcnkgU1RMICggT2N0ICA4IDIwMTMgKQ0KICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgDQoMAAAAAAAAAAAA 77%2b977%2b9AAAA77%2b9Yu%2b%2fve%2b%2fve%2b%2fve%2b%2fve%2b% 2fve%2b%2fve%2b%2fvQAAAABj77%2b9QO%2b%2fve%2b%2fve%2b%2fve%2 b%2fvQAAAABj77%2b9QO%2b%2fve%2b%2fve%2b%2fve%2b%2fvRdYIEEAAA AAAAAAAO%2b%2fve%2b%2fvQAAAO%2b%2fvWLvv73vv73vv73vv73vv73vv7 3vv70AAAAAY%2b%2b%2fvUDvv73vv73vv73vv70XWCBBYu%2b%2fve%2b%2f ve%2b%2fve%2b%2fve%2b%2fve%2b%2fve%2b%2fvRdYIEEAAAAA77%2b9Pw AAAO%2b%2fvQAAAABj77%2b9QO%2b%2fve%2b%2fve%2b%2fve%2b%2fvQAA AABj77%2b9QCbvv73vv71AAAAAAGPvv71AJu%2b%2fve%2b%2fvUAXWCBBAA AAAO%2b%2fvT8AAADvv70AAAAAY%2b%2b%2fvUDvv73vv73vv73vv70AAAAA Y%2b%2b%2fvUAm77%2b977%2b9QBdYIEFj77%2b9QO%2b%2fve%2b%2fve%2 b%2fve%2b%2fvRdYIEEAAAAAAAAAAO%2b%2fvT8AAAAAY%2b%2b%2fvUAm77 %2b977%2b9QAAAAABi77%2b977%2b977%2b9Ju%2b%2fve%2b%2fvUAAAAAA Yu%2b%2fve%2b%2fve%2b%2fvSbvv73vv71AF1ggQQAAAAAAAAAA77%2b9Pw AAAABj77%2b9QCbvv73vv71AAAAAAGLvv73vv73vv70m77%2b977%2b9QBdY IEFj77%2b9QCbvv73vv71AF1ggQQAAAADvv73vv70AAADvv70AAADvv71i77 %2b977%2b977%2b9Ju%2b%2fve%2b%2fvUAAAAAAYu%2b%2fve%2b%2fve%2 b%2fve%2b%2fve%2b%2fve%2b%2fve%2b%2fvQAAAABi77%2b977%2b977%2 b977%2b977%2b977%2b977%2b9F1ggQQAAAADvv73vv70AAADvv70AAADvv7 1i77%2b977%2b977%2b9Ju%2b%2fve%2b%2fvUAAAAAAYu%2b%2fve%2b%2f ve%2b%2fve%2b%2fve%2b%2fve%2b%2fve%2b%2fvRdYIEFi77%2b977%2b9 77%2b9Ju%2b%2fve%2b%2fvUAXWCBBAAAAAADvv70AAADvv70AAO%2b%2fve %2b%2fvWPvv71A77%2b977%2b977%2b977%2b9AAAAAGLvv73vv73vv73vv7 3vv73vv73vv70AAAAAYu%2b%2fve%2b%2fve%2b%2fvSbvv73vv71AAAAAAA AAAAAAAAAAAAAAAO%2b%2fve%2b%2fvWLvv73vv73vv70m77%2b977%2b9QA AAAABj77%2b9QCbvv73vv71AAAAAAGPvv71A77%2b977%2b977%2b977%2b9 AAAAAAAAAAAAAAAAAO%2b%2fvQAA77%2b9P2Pvv71A77%2b977%2b977%2b9 77%2b9F1ggQWLvv73vv73vv70m77%2b977%2b9QBdYIEFi77%2b977%2b977 %2b977%2b977%2b977%2b977%2b9F1ggQQAAAAAAAAAAAAAAAO%2b%2fvT9i 77%2b977%2b977%2b9Ju%2b%2fve%2b%2fvUAXWCBBY%2b%2b%2fvUDvv73v v73vv73vv70XWCBBY%2b%2b%2fvUAm77%2b977%2b9QBdYIEEAAA%3d%3d ",
    "fileName":"initial_sweep.stl",
    "hasRightsToModel":1,
    "acceptTermsAndConditions":1,
    "title":"#6 Api testing a real binary stl file..:S",
    "description":"Sweep someone off their feet with the SUUZ Initial sweep ring. This special initials ring consists of characters picked by you. Enter your initials, your lovers' intials or anything else, up to 4 characters. The charactes in this ring designed by SUUZ are connected fluently. It is a comfortable and light ring to wear. Absolutely an elegant and personal jewel! ",
    "isPublic":1,
    "isForSale":1,
    "uploadScale":0.001
    }



    the C# code for encoding the file contents is as follows:

    byte[] bytes = System.Text.Encoding.UTF8.GetBytes(filecontents);
    string filecontents_base64 = System.Convert.ToBase64String(bytes);
    string filecontents_base64_urlencoded = HttpUtility.UrlEncodeUnicode(filecontents_base64);



    anybody from the shapeways team any idea?


    chrs,
    Elco

     

    Attached Files:


  2. Suspect it's a SW bug.

    I gave up trying to upload binary files (either stl or x3db) when I was developing SW API bindings about a year ago. Text files always seem to work, binary was inconsistent - sometimes they work, sometimes not.

     
  3. hi xerces,

    thx for your reply.

    can somebody from shapeways have a look at this suspected bug?

    add on: if i closely read the api 'getting started' page it says it can handle 'binaries...'


    chrs,
    Elco




     
  4. any update on this shapeways?
     
  5. hans_lambermont
    hans_lambermont Shapeways Employee Dev Team
    [followup after mail for other forum members] The API supports binary uploads.

    Please note that base64 file data in the API needs to be URLencoded. In php this looks like :

    Code:
    $data = array( "fileName" => "$filename",
                   "file" => rawurlencode(base64_encode($file)),
                   ...
    
    In general it may be useful to download the Shapeways API Reference Clients from https://github.com/Shapeways/shapeways-api , and compare your client with the php-pecl one.

    -- Hans
     
  6. Thx for the response;

    here's the working C# code in case anyone interested in the correct functions:

    byte[] bytes = System.IO.File.ReadAllBytes(stlpath);
    string filecontents_base64 = System.Convert.ToBase64String(bytes);
    string filecontents_base64_urlencoded = HttpUtility.UrlEncodeUnicode(filecontents_base64);



    then post filecontents_base64_urlencoded as part of your json request.

     

  7. Has been long enough since I implemented an upload function that I don't recall a lot of detail. Using the apache commons codec lib function encodeBase64URLSafeString(byte[] binaryData)

    The javadoc explicitly notes that no padding is added. Have read that some decoders will consider the lack of padding to be an error.

    How does the decoder that Shapeways uses handle this condition?