diff --git a/src/soundfile.js b/src/soundfile.js index 0cc3c760..d2f3be15 100644 --- a/src/soundfile.js +++ b/src/soundfile.js @@ -1654,16 +1654,18 @@ define(function (require) { }; /** - * This method is useful for sending a SoundFile to a server. It returns a URL to - * the .wav-encoded audio data as a "Blob". A Blob is a * file-like data object that can be uploaded to a server with an httpPost request. + * href="/docs/reference/#/p5/httpDo">http request. We'll use + * the `httpDo` options object to send a POST request with some specific options: + * we encode the request as `multipart/form-data`, + * and attach the blob as one of the form values using `FormData`. + * * - * @method saveBlob - * @returns {ObjectURL} URL to the Blob of audio data. This URL is local to the browser, - * but can be sent to a server with an httpPost - * request. + * @method getBlob + * @returns {Blob} A file-like data object * @example *
*
@@ -1672,20 +1674,39 @@ define(function (require) {
* }
*
* function setup() {
- * var dataUrl = mySound.saveBlob();
-
- * text("Here's the Blob!", 0, height - 5);
- * var input = createInput(dataUrl);
- *
+ * noCanvas();
+ * var soundBlob = mySound.getBlob();
+ *
+ * // Now we can send the blob to a server...
+ * var serverUrl = 'https://jsonplaceholder.typicode.com/posts';
+ * var httpRequestOptions = {
+ * method: 'POST',
+ * body: new FormData().append('soundBlob', soundBlob),
+ * headers: new Headers({
+ * 'Content-Type': 'multipart/form-data'
+ * })
+ * };
+ * httpDo(serverUrl, httpRequestOptions);
+ *
+ * // We can also create an `ObjectURL` pointing to the Blob
+ * var blobUrl = URL.createObjectURL(soundBlob);
+ *
+ * // The `