Bluemixオブジェクト保存にアップロードするファイルは、requestモジュールです。すべてが良いですが、自動的に追加するいくつかの不要な文字があります。nodejs put要求に不要な文字を自動的に追加します
example:
--38oi85df-b5d1-4d42-81ce-c547c860b512 //this is unwanted character
Email
[email protected]
[email protected]
[email protected]
--38oi85df-b5d1-4d42-81ce-c547c860b512-- // this is unwanted character
はここに私のコードです: -
import request from 'request';
exports.putObjectStorageFile = function(authToken, file, csv, cb) {
var s = new stream.Readable();
s._read = function noop() {};
s.push(csv); //csv is string
s.push(null);
var options = {
url: 'https://xxxx.objectstorage.open.xxxx.com/v1/AUTH_' + config.objectStorage.projectId + '/xxxx/' + file,
method: 'PUT',
preambleCRLF: true,
postambleCRLF: true,
encoding: 'utf-8',
headers: {
'Content-Type': 'text/html; charset=UTF-8',
'Content-Length': 1,
'X-Auth-Token': authToken
},
multipart: {
chunked: false,
data: [
{ body: s }
]
} };
function callback(error, response) {
if (error) cb(error);
if (!error && response.statusCode == 201) {
cb(null);
}
}
request(options, callback);
私たちはzipファイルをアップロードできますか?コンテンツタイプ、コンテンツの長さを追加して本文にデータを送信することで解決策を見つけましたか? –