Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

A strophe.js plugin for file upload using HTTP File Upload (XEP-0363)

License

AnishLushte07/strophejs-plugin-http-file-upload

Repository files navigation

Strophe http-file-upload

Plugin for strophe.js to provide HTTP File Upload (XEP-0363).

Install

This is a Node.js module available through the npm registry. Installation is done using the npm install command:

$ npm install strophejs-plugin-http-file-upload

Initialization

connection.httpUpload.init(connection);

Usage

Generate GET and PUT URL for file

connection.httpUpload.getUrls(file, success_cb, error_cb)

file is the File object which you want to upload.

success_cb is a function to be called on success with urls:

error_cb is a function to be called in case of error.

Function will return object with put and get url. You can use put url to upload file using http.

Example

Generate get and put url for file:

var file = {
 name: 'filename.png',
 size: 4512, // in bytes
 type: 'image/png',
 ... // other data
}
function uploadFile(file, url) {
 var xhr = new XMLHttpRequest();
 xhr.onreadystatechange = function() {
 if (xhr.readyState === 4) {
 console.log('File Uploaded Successfully.');
 }
 };
 xhr.open("PUT", url, true);
 xhr.setRequestHeader('Content-Type', 'text/plain');
 xhr.send(file);
}
connection.httpUpload.getUrls(
 file,
 function(data) {
 console.log("PUT URL: ", data.put, "GET URL: ", data.get);
 uploadFile(file, data.put);
 return true;
 },
 function(err) {
 console.error(err);
 }
);

License

strophejs-plugin-http-file-upload is copyright (c) 2019-present Anish Lushte lushteanish@gmail.com and the contributors to Node-Minio.

strophejs-plugin-http-file-upload is free software, licensed under the MIT License. See the LICENSE file for more details.

About

A strophe.js plugin for file upload using HTTP File Upload (XEP-0363)

Topics

Resources

License

Code of conduct

Contributing

Stars

Watchers

Forks

Packages

No packages published

AltStyle によって変換されたページ (->オリジナル) /