{"id":23701150,"url":"https://github.com/ehanlin/image-uploader-api","last_synced_at":"2025-10-27T20:46:11.153Z","repository":{"id":58232535,"uuid":"106529544","full_name":"eHanlin/image-uploader-api","owner":"eHanlin","description":"The `image-uploader-api` is a upload API, it implement multipart format.","archived":false,"fork":false,"pushed_at":"2017-10-11T09:05:29.000Z","size":33,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":5,"default_branch":"master","last_synced_at":"2024-04-27T08:22:50.916Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/eHanlin.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-10-11T08:52:22.000Z","updated_at":"2017-10-11T08:52:45.000Z","dependencies_parsed_at":"2022-08-30T22:30:28.368Z","dependency_job_id":null,"html_url":"https://github.com/eHanlin/image-uploader-api","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eHanlin%2Fimage-uploader-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eHanlin%2Fimage-uploader-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eHanlin%2Fimage-uploader-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eHanlin%2Fimage-uploader-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/eHanlin","download_url":"https://codeload.github.com/eHanlin/image-uploader-api/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239776624,"owners_count":19695143,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-12-30T09:32:18.501Z","updated_at":"2025-10-27T20:46:06.111Z","avatar_url":"https://github.com/eHanlin.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"image-uploader-api\n===========================\n\nThe `image-uploader-api` is a upload API, it implement multipart format.\n\nYou can use this client api if you don't want to depend on other packages.\n\n## Install\n\n**npm：**\n```sh\nnpm install image-uploader-api\n```\n\n**bower：**\n```sh\nbower install image-uploader-api\n```\n\n\n## Usage\n\nThe api use like this：\n\n```js\nlet context = imageUploaderApi.createContext(url);\n\nlet promise = context.upload('your key', fileBlob);\npromise.then(()=\u003e console.log('done'), ()=\u003e console.log('error'));\n```\n\n## API\n\n#### imageUploaderApi.createContexnt(url:String) : ImageUploaderApiContext\n\nCreate an ImageUploaderApiContext.\n\n* url(required): The parameter is api host.\n\n\n#### ImageUploaderApiContext(url:String)\n\nFor `ImageUploaderApiContext`, it's a context object that is able to set some of default parameters.\n\n* url(required): The parameter is api host.\n\n##### upload(key:String, fileBlob:Blob, decorateDescriptor:function?, uploadCB:function?) : Promise\n\n* key(required): Be able to be filename or path.\n* fileBlob(required): File content will be uploaded to server.\n* decorateDescriptor(optional): The function is able to decorate default descriptor of image, and it will be send to server to be processed.\n\n```js\nfunction decorateDescriptor(descriptor) {\n  descriptor['version'] = '1.0.0';\n}\n```\n\n* uploadCB(optional): The function will be called when the progress succeeed with file where to upload server.\n\n\n**See default descriptor below：**\n\n```js\n{  \n   \"screen\":{  \n      \"availHeight\":773,\n      \"availLeft\":0,\n      \"availTop\":23,\n      \"availWidth\":1280,\n      \"colorDepth\":24,\n      \"height\":800,\n      \"pixelDepth\":24,\n      \"width\":1280\n   },\n   \"width\":1264,\n   \"height\":41,\n   \"documentHeight\":351,\n   \"documentWidth\":1280,\n   \"url\":\"http://0.0.0.0:8080/build/\",\n   \"userAgent\":\"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36\"\n}\n```\n\n## Server side\n\nImplement your http api if you want to receive form data from this client api.\n\nYou need be able to parse format from content type of `multipart/form-data` and method of `POST`, and it send the parameters of `key` 、 `file` and `content` to your server.\n\nIf you don't know what to parse `multipart/form-data` format, be able to use some packages from third-party like [busboy](https://github.com/mscdex/busboy) or [multer](https://github.com/expressjs/multer).\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fehanlin%2Fimage-uploader-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fehanlin%2Fimage-uploader-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fehanlin%2Fimage-uploader-api/lists"}