Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upload asset via API #763

Open
paulstelzer opened this issue May 13, 2018 · 1 comment

Comments

Projects
None yet
2 participants
@paulstelzer
Copy link

commented May 13, 2018

Hello, I saw in Commit b63202e7100b09ac03b0a0d10f645cc78131c311 that the rest api now contains a addAssets() function.

Is there a documentation available how to use it?

@johannesvg

This comment has been minimized.

Copy link

commented Oct 30, 2018

Hello, I saw in Commit b63202e7100b09ac03b0a0d10f645cc78131c311 that the rest api now contains a addAssets() function.

Is there a documentation available how to use it?

This works for me. Just make sure that the API url receives a post request containing the files to upload. the block brackets are apparently required in order to force the php $_FILES variable in an array format, which is needed for the current implementation of the code.

    <form method="POST" id="formid" enctype="multipart/form-data">
        <input type="file" name="files[]">
        <input type="submit" id="test" value="ok">
    </form>

    <script>
    
    $( document ).ready(function() {

        $( '#formpid' )
        .submit( function( e ) {
            $.ajax( {
            url: 'xxx/api/cockpit/addAssets?token=xxx',
            type: 'POST',
            data: new FormData( this ),
            processData: false,
            contentType: false
            } );
            e.preventDefault();
        } );
    
    });

    </script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.