You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
asyncupload(file,path){if(this.ref.path){path=this.ref.path.replace(/[^/]+$/,"")+path;// make upload path relative to existing path}else{path=path.startsWith("/") ? path : "/"+path;}constref=this._getRef(path);awaitthis.put(file,{ref,isUploading: true});returnthis.getURL(path);}
backends/github/file/github-file.js:
asyncupload(file,path=this.ref.path){letdataURL=awaitreadFile(file);letbase64=dataURL.slice(5);// remove data:letmedia=base64.match(/^\w+\/[\w+]+/)[0];media=media.replace("+","\\+");// Fix for #608base64=base64.replace(RegExp(`^${media}(;base64)?,`),"");path=this.ref.path.replace(/[^/]+$/,"")+path;// make upload path relative to existing pathletfileInfo=awaitthis.put(base64,{ref: path,isEncoded: true});returnthis.getFileURL(path,{sha: fileInfo.commit.sha});}
asyncupload(file,{filename =file.name, folder}={}){constmetadata={name: filename};if(folder){constfolderId=GoogleDrive.#getFolderId(folder);if(folderId){metadata.parents=[folderId];}}constres=awaitthis.request("upload/drive/v3/files?&fields=webViewLink&uploadType=resumable",metadata,"POST",{responseType: "response"});constcall=res.headers.get("Location");try{constfileInfo=awaitthis.request(call,file,"PATCH");returnfileInfo.webViewLink;}catch({ error }){if(error.code===401){awaitthis.logout();// Access token we have is invalid. Discard it.thrownewError(this.constructor.phrase("access_token_invalid"));}elseif(error.code===403){thrownewError(this.constructor.phrase("no_upload_permission"));}thrownewError(error.message);}}
We should harmonize these signatures.
We should not be duplicating code that deals with relative paths in the actual backends. If we know it’s file based, we can do that in a superclass. That's the whole point of the fileBased key.
I haven't looked at put() but I suspect the findings will be similar.
The text was updated successfully, but these errors were encountered:
We have three backends with
fileBased = true
.backends/dropbox/index.js
:backends/github/file/github-file.js
:fileBased
key.I haven't looked at
put()
but I suspect the findings will be similar.The text was updated successfully, but these errors were encountered: