Comments (9)
Wondering how to handle this. The S3 metadata response doesn't provide the file size either, so instead I download the whole file and check its length. This is very inefficient for big files! Inefficient and incorrect are both bad, but we should at least pick one so its consistent across providers. Which one should we use?
Another option is to return -1 or another invalid value as an error code for backends that don't support efficient retrieval of the size, and only have a valid value present for backends that do provide the size efficiently as a number in the metadata response. I'm inclined to go with this.
Thoughts @jmuk @mtomasz-chromium?
from chromeos-filesystems.
Or the provider could have a method like hasCorrectSize
that the FSP API can call to check if it will be returning a valid size, and use this to determine whether to show the size in the browser.
from chromeos-filesystems.
The current file system implementation requires a file size, and bad things may happen if we don't provide it.
Can we get the file size from the Content-Length field using a HEAD HTTP request? That's still inefficient, but at least we wouldn't need to download the entire file. Would it work?
from chromeos-filesystems.
According to http://docs.aws.amazon.com/AmazonS3/latest/API/RESTBucketGET.html, AWS S3 does provide the size.
from chromeos-filesystems.
That would probably work for WebDAV (although might depend on the server implementation). It might be in the AWS raw REST API but I don't think it's in the JS library - the response of headObject
doesn't return a size, and that uses HTTP HEAD.
Even if we can get it working for the current two, we should still plan for the eventuality of a provider coming along whose API does not provide an efficient way to get the size of a file, and a way for them to handle it.
from chromeos-filesystems.
I'm not sure if I understand. The AWS API returns the size according to the link you provided:
"ContentLength — (Integer) Size of the body in bytes."
from chromeos-filesystems.
As for WebDAV, did you consider specifying the "getcontentlength" field in the request? http://msdn.microsoft.com/en-us/library/ms879496(v=exchg.65).aspx
from chromeos-filesystems.
Huh okay I totally skipped over that property. I guess I was just looking for something called size
. I will try working with custom requests for WebDAV. Currently it just fetches the default response (sends no data in the request) but I guess it won't be too hard to customise.
from chromeos-filesystems.
WebDAV is fixed in #42 and S3 is fixed in #52. Closing.
from chromeos-filesystems.
Related Issues (20)
- Update truncate method name
- Refactor out chrome mock
- Comment all Gruntfile tasks
- Ways to mock the S3 API HOT 1
- bowerjs
- what is this for HOT 1
- Feature Request: add startIn attribute for ChooseEntry
- Write operations behaviour questions HOT 1
- Challenges with S3 and Write operations
- Can't get WebDAV copy to work HOT 3
- Update new write operations to assign to a variable before exporting to JSDoc can pick them up
- S3FS onWriteFileRequested JSDoc description is wrong
- Write events are not actually registered with the filesystem
- Add lint task for CI
- Condense S3 events into one file
- WebDAV onWriteFileRequested JSDoc is wrong
- Reset filesystem between every test run HOT 2
- Remove Makefiles
- Tidy up WebDAV events file
- Add error handling for S3 HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from chromeos-filesystems.