Skip to content

Allows user to provide absolute URLs for upload. - #18

Closed
NeoXtreme wants to merge 1 commit into
milo:masterfrom
NeoXtreme:upload_url_support
Closed

NeoXtreme wants to merge 1 commit into
milo:masterfrom
NeoXtreme:upload_url_support

Conversation

@NeoXtreme

@NeoXtreme NeoXtreme commented Oct 26, 2016 •

Copy link
Copy Markdown

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

milo commented Oct 27, 2016

Copy link
Copy Markdown
Owner

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

@NeoXtreme

Copy link
Copy Markdown
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