@simplysf/simply-data 2.3.26 → 2.3.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +12 -4
- package/lib/common/contentVersionUtils.d.ts +8 -3
- package/lib/common/contentVersionUtils.js +15 -9
- package/lib/common/contentVersionUtils.js.map +1 -1
- package/messages/simply.data.file.upload.md +3 -1
- package/messages/simply.data.files.upload.md +2 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -37,7 +37,8 @@ FLAGS
|
|
|
37
37
|
-o, --target-org=<value> (required) Username or alias of the target org. Not required if the
|
|
38
38
|
`target-org` configuration variable is already set.
|
|
39
39
|
--api-version=<value> Override the api version used for api requests made by this command
|
|
40
|
-
--file-path=<value> (required) Path to the file to upload.
|
|
40
|
+
--file-path=<value> (required) Path to the file to upload. May be relative or absolute; only the
|
|
41
|
+
file's name is sent to the org.
|
|
41
42
|
--first-publish-location-id=<value> Specify a record Id that the file should be linked to.
|
|
42
43
|
--title=<value> Specify the title for the file being uploaded.
|
|
43
44
|
|
|
@@ -50,13 +51,16 @@ DESCRIPTION
|
|
|
50
51
|
|
|
51
52
|
Uploads a file to a Salesforce org.
|
|
52
53
|
|
|
54
|
+
Only the file's name is sent to the org — Salesforce stores it as the ContentVersion's PathOnClient and derives
|
|
55
|
+
FileExtension and FileType from it — so the local directory the file came from is never uploaded.
|
|
56
|
+
|
|
53
57
|
EXAMPLES
|
|
54
58
|
$ sf simply data file upload --file-path fileToUpload.txt --target-org myTargetOrg
|
|
55
59
|
|
|
56
60
|
$ sf simply data file upload --file-path fileToUpload.txt --first-publish-location-id 0019000000DmehK --target-org myTargetOrg
|
|
57
61
|
```
|
|
58
62
|
|
|
59
|
-
_See code: [lib/commands/simply/data/file/upload.js](https://github.com/SimplySF/simply-node/blob/@simplysf/simply-data@2.3.
|
|
63
|
+
_See code: [lib/commands/simply/data/file/upload.js](https://github.com/SimplySF/simply-node/blob/@simplysf/simply-data@2.3.27/packages/simply-data/lib/commands/simply/data/file/upload.js)_
|
|
60
64
|
|
|
61
65
|
## `sf simply data files download`
|
|
62
66
|
|
|
@@ -101,7 +105,7 @@ FLAG DESCRIPTIONS
|
|
|
101
105
|
Provide a WHERE clause to allow the plugin to specify which ContentVersion records should be downloaded.
|
|
102
106
|
```
|
|
103
107
|
|
|
104
|
-
_See code: [lib/commands/simply/data/files/download.js](https://github.com/SimplySF/simply-node/blob/@simplysf/simply-data@2.3.
|
|
108
|
+
_See code: [lib/commands/simply/data/files/download.js](https://github.com/SimplySF/simply-node/blob/@simplysf/simply-data@2.3.27/packages/simply-data/lib/commands/simply/data/files/download.js)_
|
|
105
109
|
|
|
106
110
|
## `sf simply data files upload`
|
|
107
111
|
|
|
@@ -140,13 +144,17 @@ FLAG DESCRIPTIONS
|
|
|
140
144
|
The csv file must specify the columns PathOnClient and Title. Optionally, a FirstPublishLocationId can be specified
|
|
141
145
|
to have it linked directly to a Salesforce record after upload.
|
|
142
146
|
|
|
147
|
+
PathOnClient is the local path each file is read from, and may be relative or absolute. Only the file's name is sent
|
|
148
|
+
to the org — Salesforce stores it as the ContentVersion's PathOnClient and derives FileExtension and FileType from
|
|
149
|
+
it — so the local directory the file came from is never uploaded.
|
|
150
|
+
|
|
143
151
|
--max-parallel-jobs=<value> Maximum number of parallel jobs.
|
|
144
152
|
|
|
145
153
|
By default the plugin will only process a single file upload at a time. You can increase this value to allow for
|
|
146
154
|
quasi concurrent uploads. Please note that setting this value too high can cause performance issues.
|
|
147
155
|
```
|
|
148
156
|
|
|
149
|
-
_See code: [lib/commands/simply/data/files/upload.js](https://github.com/SimplySF/simply-node/blob/@simplysf/simply-data@2.3.
|
|
157
|
+
_See code: [lib/commands/simply/data/files/upload.js](https://github.com/SimplySF/simply-node/blob/@simplysf/simply-data@2.3.27/packages/simply-data/lib/commands/simply/data/files/upload.js)_
|
|
150
158
|
<!-- commandsstop -->
|
|
151
159
|
|
|
152
160
|
## License
|
|
@@ -14,12 +14,17 @@ export declare function downloadContentVersion(targetOrgConnection: Connection,
|
|
|
14
14
|
/**
|
|
15
15
|
* Upload a local file as a new `ContentVersion`.
|
|
16
16
|
*
|
|
17
|
+
* Only the file's name is sent to the org as `PathOnClient`, not the local path it was read from.
|
|
18
|
+
* Salesforce derives `FileExtension` and `FileType` from that value, so the name is all it needs —
|
|
19
|
+
* and sending the rest would publish the uploader's local directory layout into the org, where it
|
|
20
|
+
* is visible to anyone who can query `ContentVersion`.
|
|
21
|
+
*
|
|
17
22
|
* @param targetOrgConnection - The org connection to upload to.
|
|
18
|
-
* @param
|
|
19
|
-
* @param title - The `ContentVersion` title. Defaults to the file's
|
|
23
|
+
* @param filePath - The local filesystem path of the file to upload. Stays local.
|
|
24
|
+
* @param title - The `ContentVersion` title. Defaults to the file's name.
|
|
20
25
|
* @param firstPublishLocationId - The ID of the record/library to attach the resulting
|
|
21
26
|
* `ContentDocument` to, if any.
|
|
22
27
|
* @returns The created `ContentVersion`, re-queried to include `ContentDocumentId`.
|
|
23
28
|
* @throws {SfError} If the org returns a non-2xx response.
|
|
24
29
|
*/
|
|
25
|
-
export declare function uploadContentVersion(targetOrgConnection: Connection,
|
|
30
|
+
export declare function uploadContentVersion(targetOrgConnection: Connection, filePath: string, title?: string, firstPublishLocationId?: string): Promise<ContentVersion>;
|
|
@@ -71,26 +71,32 @@ export async function downloadContentVersion(targetOrgConnection, contentVersion
|
|
|
71
71
|
/**
|
|
72
72
|
* Upload a local file as a new `ContentVersion`.
|
|
73
73
|
*
|
|
74
|
+
* Only the file's name is sent to the org as `PathOnClient`, not the local path it was read from.
|
|
75
|
+
* Salesforce derives `FileExtension` and `FileType` from that value, so the name is all it needs —
|
|
76
|
+
* and sending the rest would publish the uploader's local directory layout into the org, where it
|
|
77
|
+
* is visible to anyone who can query `ContentVersion`.
|
|
78
|
+
*
|
|
74
79
|
* @param targetOrgConnection - The org connection to upload to.
|
|
75
|
-
* @param
|
|
76
|
-
* @param title - The `ContentVersion` title. Defaults to the file's
|
|
80
|
+
* @param filePath - The local filesystem path of the file to upload. Stays local.
|
|
81
|
+
* @param title - The `ContentVersion` title. Defaults to the file's name.
|
|
77
82
|
* @param firstPublishLocationId - The ID of the record/library to attach the resulting
|
|
78
83
|
* `ContentDocument` to, if any.
|
|
79
84
|
* @returns The created `ContentVersion`, re-queried to include `ContentDocumentId`.
|
|
80
85
|
* @throws {SfError} If the org returns a non-2xx response.
|
|
81
86
|
*/
|
|
82
|
-
export async function uploadContentVersion(targetOrgConnection,
|
|
87
|
+
export async function uploadContentVersion(targetOrgConnection, filePath, title, firstPublishLocationId) {
|
|
83
88
|
// Check that we have access to the file
|
|
84
|
-
await fs.promises.access(
|
|
89
|
+
await fs.promises.access(filePath, fs.constants.F_OK);
|
|
90
|
+
const fileName = path.basename(filePath);
|
|
85
91
|
const contentVersionCreateRequest = {
|
|
86
92
|
FirstPublishLocationId: firstPublishLocationId,
|
|
87
|
-
PathOnClient:
|
|
88
|
-
Title: title ??
|
|
93
|
+
PathOnClient: fileName,
|
|
94
|
+
Title: title ?? fileName,
|
|
89
95
|
};
|
|
90
96
|
const { contentType, createBody } = contentVersionMultipart({
|
|
91
97
|
entity: contentVersionCreateRequest,
|
|
92
|
-
filePath
|
|
93
|
-
filename:
|
|
98
|
+
filePath,
|
|
99
|
+
filename: fileName,
|
|
94
100
|
});
|
|
95
101
|
const response = await fetch(`${targetOrgConnection.baseUrl()}/sobjects/ContentVersion`, {
|
|
96
102
|
method: 'POST',
|
|
@@ -103,7 +109,7 @@ export async function uploadContentVersion(targetOrgConnection, pathOnClient, ti
|
|
|
103
109
|
},
|
|
104
110
|
});
|
|
105
111
|
if (!response.ok) {
|
|
106
|
-
throw await responseError(response, `Upload of "${
|
|
112
|
+
throw await responseError(response, `Upload of "${filePath}"`);
|
|
107
113
|
}
|
|
108
114
|
const data = (await response.json());
|
|
109
115
|
const queryResult = await targetOrgConnection.singleRecordQuery(`SELECT ContentDocumentId, FileExtension, Id, Title FROM ContentVersion WHERE Id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CAAC;IAED,MAAM,IAAI,GAAG,CAAC,MAAM,QAAQ,CAAC,IAAI,EAAE,CAA+B,CAAC;IAEnE,MAAM,WAAW,GAAG,MAAM,mBAAmB,CAAC,iBAAiB,CAC7D,oFAAoF,IAAI,CAAC,EAAE,GAAG,CAC/F,CAAC;IAEF,OAAO,WAA6B,CAAC;AACvC,CAAC"}
|
|
@@ -6,9 +6,11 @@ Upload a file to a Salesforce org.
|
|
|
6
6
|
|
|
7
7
|
Uploads a file to a Salesforce org.
|
|
8
8
|
|
|
9
|
+
Only the file's name is sent to the org — Salesforce stores it as the ContentVersion's PathOnClient and derives FileExtension and FileType from it — so the local directory the file came from is never uploaded.
|
|
10
|
+
|
|
9
11
|
# flags.file-path.summary
|
|
10
12
|
|
|
11
|
-
Path to the file to upload.
|
|
13
|
+
Path to the file to upload. May be relative or absolute; only the file's name is sent to the org.
|
|
12
14
|
|
|
13
15
|
# flags.first-publish-location-id.summary
|
|
14
16
|
|
|
@@ -14,6 +14,8 @@ Path to the csv file that specifies the upload.
|
|
|
14
14
|
|
|
15
15
|
The csv file must specify the columns PathOnClient and Title. Optionally, a FirstPublishLocationId can be specified to have it linked directly to a Salesforce record after upload.
|
|
16
16
|
|
|
17
|
+
PathOnClient is the local path each file is read from, and may be relative or absolute. Only the file's name is sent to the org — Salesforce stores it as the ContentVersion's PathOnClient and derives FileExtension and FileType from it — so the local directory the file came from is never uploaded.
|
|
18
|
+
|
|
17
19
|
# flags.max-parallel-jobs.summary
|
|
18
20
|
|
|
19
21
|
Maximum number of parallel jobs.
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@simplysf/simply-data",
|
|
3
3
|
"description": "Utilities for working with data",
|
|
4
|
-
"version": "2.3.
|
|
4
|
+
"version": "2.3.27",
|
|
5
5
|
"author": "@ClayChipps",
|
|
6
6
|
"homepage": "https://github.com/SimplySF/simply-node",
|
|
7
7
|
"bugs": "https://github.com/SimplySF/simply-node/issues",
|
|
@@ -214,5 +214,5 @@
|
|
|
214
214
|
"output": []
|
|
215
215
|
}
|
|
216
216
|
},
|
|
217
|
-
"gitHead": "
|
|
217
|
+
"gitHead": "5227ae680ff4f42e4842b090e50826930dcc67b1"
|
|
218
218
|
}
|