什麼?
隨著網路的普及,很多人都搭建起了屬於自己的nextcloud私有網盤。而對於訪問量較大,公開性較強的私有網盤站點來說,許多人通常會使用CDN來保護自身免受攻擊。 使用了CDN之後對於私有網盤而言,繞不開的一個問題就是單文件上傳大小的限製,比如源站服務器允許1G大小單文件,到了CDN這裏卻只允許100M,於是用戶就只能上傳100M了,非常不方便。
嗯?
繞過上傳限製的辦法麽 ~ 除了氪金,似乎就只有分片上傳了。好在nextcloud本身支持web界面開啟分片上傳,以下是具體方法(僅對web端有效,sync或者webdav仍然受單文件上傳大小限製):
1.首先,確認自己的web服務器的php允許上傳大小在自己滿意的範圍。(修改php.ini的max_upload_file_size數值實現) 2.打開nextcloud根目錄,進入 apps/files/js目錄,找到 jquery.fileupload.js,並使用編輯器打開。 3.跳轉到154行附近,找到 maxChunkSize 這個選項。把這個選項後面的默認值改為其他數值。
默認情況:
// To upload large files in smaller chunks, set the following option
// to a preferred maximum chunk size. If set to 0, null or undefined,
// or the browser does not support the required Blob API, files will
// be uploaded as a whole.
maxChunkSize: undefined, //就是這
// When a non-multipart upload or a chunked multipart upload has been
// aborted, this option can be used to resume the upload by setting
// it to the size of the already uploaded bytes. This option is most
// useful when modifying the options object inside of the "add" or
// "send" callbacks, as the options are cloned for each file upload.
uploadedBytes: undefined,
例如可以修改為 100000000 (約合98MB),並保存退出:
// To upload large files in smaller chunks, set the following option
// to a preferred maximum chunk size. If set to 0, null or undefined,
// or the browser does not support the required Blob API, files will
// be uploaded as a whole.
maxChunkSize: 100000000, //就是這
// When a non-multipart upload or a chunked multipart upload has been
// aborted, this option can be used to resume the upload by setting
// it to the size of the already uploaded bytes. This option is most
// useful when modifying the options object inside of the "add" or
// "send" callbacks, as the options are cloned for each file upload.
uploadedBytes: undefined,
此時再打開web界面,刷新快取以後就可以上傳大於100M的單個文件了。
有什麽副作用?
1.由於文件上傳完畢後需要服務器組合,如果網絡狀況不佳或者服務器配置跟不上訪問量,所以上傳特大文件時可能會突然遇到無響應問題。
2.上傳處理效能會變差很多。因為nextcloud對這方面並沒有優化。
