File tree Expand file tree Collapse file tree 5 files changed +47
-5
lines changed Expand file tree Collapse file tree 5 files changed +47
-5
lines changed Original file line number Diff line number Diff line change 1
1
# Changelog
2
+ ## 2.2.0
3
+ - Implemented automatic string cleaning to prevent file save errors.
4
+
2
5
## 2.1.3
3
6
- Implemented Prettier.
4
7
- Formated files with Prettier.
Original file line number Diff line number Diff line change
1
+ // returns a string that has been striped of all characters that would
2
+ // cause errors in dropbox
3
+
4
+ const cleanString = str =>
5
+ str
6
+ . replace ( / \* / g, "" )
7
+ . replace ( / \| / g, "" )
8
+ . replace ( / & / g, "" )
9
+ . replace ( / ! / g, "" )
10
+ . replace ( / @ / g, "" )
11
+ . replace ( / # / g, "" )
12
+ . replace ( / \$ / g, "" )
13
+ . replace ( / % / g, "" )
14
+ . replace ( / \^ / g, "" )
15
+ . replace ( / \( / g, "" )
16
+ . replace ( / \) / g, "" )
17
+ . replace ( / - / g, "" )
18
+ . replace ( / _ / g, "" )
19
+ . replace ( / \+ / g, "" )
20
+ . replace ( / = / g, "" )
21
+ . replace ( / ~ / g, "" )
22
+ . replace ( / ` / g, "" )
23
+ . replace ( / " / g, "" )
24
+ . replace ( / ' / g, "" )
25
+ . replace ( / ; / g, "" )
26
+ . replace ( / : / g, "" )
27
+ . replace ( / > / g, "" )
28
+ . replace ( / < / g, "" )
29
+ . replace ( / \{ / g, "" )
30
+ . replace ( / \} / g, "" )
31
+ . replace ( / \[ / g, "" )
32
+ . replace ( / \] / g, "" )
33
+ . replace ( / \? / g, "" )
34
+
35
+ module . exports = cleanString
Original file line number Diff line number Diff line change 2
2
const { Transform } = require ( "stream" )
3
3
const Dropbox = require ( "dropbox" )
4
4
const streamLength = require ( "stream-length" )
5
+ const cleanString = require ( "./cleanString" )
5
6
6
7
// Dropbox Upload Stream
7
8
class DropboxUploadStream extends Transform {
@@ -89,7 +90,7 @@ class DropboxUploadStream extends Transform {
89
90
offset : this . offset , // offset, current location of chunk
90
91
} ,
91
92
commit : {
92
- path : this . options . saveLocation , // path to save thew new file
93
+ path : cleanString ( this . options . saveLocation ) , // path to save thew new file
93
94
mode : "add" , // add mode, this will NOT overwrite an existing file
94
95
autorename : true , // if there is duplicates rename ex. file(2).txt
95
96
mute : false , // show notifications to db users that files were changed
@@ -99,7 +100,9 @@ class DropboxUploadStream extends Transform {
99
100
// we are finished uploading the file
100
101
if ( this . options . debugMode ) {
101
102
console . log (
102
- `Filed Uploaded for save location ${ this . options . saveLocation } `
103
+ `Filed Uploaded for save location ${ cleanString (
104
+ this . options . saveLocation
105
+ ) } `
103
106
)
104
107
}
105
108
Original file line number Diff line number Diff line change 1
1
// import modules
2
2
const { Transform } = require ( "stream" )
3
+ const cleanString = require ( "./cleanString" )
3
4
4
5
class TransformStream extends Transform {
5
6
constructor ( options ) {
@@ -37,7 +38,7 @@ class TransformStream extends Transform {
37
38
console . log (
38
39
`Passing buffer (size: ${ Math . round (
39
40
this . buffer . byteLength / 1024
40
- ) } KB) for save location ${ this . options . saveLocation } `
41
+ ) } KB) for save location ${ cleanString ( this . options . saveLocation ) } `
41
42
)
42
43
}
43
44
@@ -58,7 +59,7 @@ class TransformStream extends Transform {
58
59
console . log (
59
60
`Passing buffer (size: ${ Math . round (
60
61
this . buffer . byteLength / 1024
61
- ) } KB) for save location ${ this . options . saveLocation } `
62
+ ) } KB) for save location ${ cleanString ( this . options . saveLocation ) } `
62
63
)
63
64
}
64
65
Original file line number Diff line number Diff line change 1
1
{
2
2
"name" : " dropbox_session_upload" ,
3
- "version" : " 2.1.3 " ,
3
+ "version" : " 2.2.0 " ,
4
4
"description" : " Node wrapper around the dropbox upload session API to help concurrently upload files over 150mb to dropbox." ,
5
5
"main" : " index.js" ,
6
6
"scripts" : {
You can’t perform that action at this time.
0 commit comments