Skip to content

Commit 233ceac

Browse files
committed
iterate on saving functionality
1 parent 547ec44 commit 233ceac

File tree

2 files changed

+23
-14
lines changed

2 files changed

+23
-14
lines changed

src/contents.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -460,11 +460,11 @@ export class Drive implements Contents.IDrive {
460460
? localPath.substring(localPath.indexOf('/') + 1)
461461
: '';
462462

463-
const resp = await saveFile(currentDrive.name, {
463+
const data = await saveFile(currentDrive.name, {
464464
path: relativePath,
465-
param: options
465+
param: options,
466+
registeredFileTypes: this._registeredFileTypes
466467
});
467-
console.log('contents resp: ', resp);
468468

469469
Contents.validateContentsModel(data);
470470
this._fileChanged.emit({

src/requests.ts

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -143,24 +143,33 @@ export async function saveFile(
143143
options: {
144144
path: string;
145145
param: Partial<Contents.IModel>;
146+
registeredFileTypes: IRegisteredFileTypes;
146147
}
147148
) {
148-
// const [fileType, fileMimeType, fileFormat] = getFileType(
149-
// PathExt.extname(PathExt.basename(options.path)),
150-
// options.registeredFileTypes
151-
// );
152-
153-
// const formattedBody = Private.formatBody(options.param, fileFormat, fileType, fileMimeType);
154-
// const body: ReadonlyJSONObject = {
155-
// content: formattedBody
156-
// };
157-
158149
const response = await requestAPI<any>(
159150
'drives/' + driveName + '/' + options.path,
160151
'PUT',
161152
{
162153
content: options.param.content
163154
}
164155
);
165-
console.log('response: ', response);
156+
157+
const [fileType, fileMimeType, fileFormat] = getFileType(
158+
PathExt.extname(PathExt.basename(options.path)),
159+
options.registeredFileTypes
160+
);
161+
162+
data = {
163+
name: PathExt.basename(options.path),
164+
path: PathExt.join(driveName, options.path),
165+
last_modified: response.data.last_modified,
166+
created: response.data.last_modified,
167+
content: response.data.content,
168+
format: fileFormat as Contents.FileFormat,
169+
mimetype: fileMimeType,
170+
size: response.data.size,
171+
writable: true,
172+
type: fileType
173+
};
174+
return data;
166175
}

0 commit comments

Comments
 (0)