Skip to content

Conversation

NeoXtreme
Copy link

@NeoXtreme NeoXtreme commented Oct 26, 2016

Prepend API URL only if provided URL is relative. So that "https://uploads.github.com" can be supplied for uploading release assets. User can upload file by doing something like following:

function upload_zip($repo_name, $release_id, $file_name, $file_path)
{
    global $api;  //Global instance of API class, better to use it as a member of some wrapper class, just for example here.

    $up_url = 'https://uploads.github.com/repos/alcanttor/'.$repo_name.'/releases/'.$release_id.'/assets?name='.$file_name;

    $up_header = ['Content-Type' => 'application/zip'];

    $response = $api->post($up_url, file_get_contents($file_path), [], $up_header);

    if($response->getCode() != 201)
        return false;
    else
        return true;
}

Prepend API URL only if provided URL is relative.
milo added a commit that referenced this pull request Oct 27, 2016
@milo milo closed this in 1fcb441 Oct 27, 2016
@milo
Copy link
Owner

milo commented Oct 27, 2016

Thank you for the PR @NeoXtreme , but I fixed it in a slightly different way.

@NeoXtreme
Copy link
Author

Thank you for the update. I am using your library for github script for our in-house projects, that is when I needed to make this patch. I will now update to the latest patch from your repo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants