util.readFile(file, function(data) { self.reading = false; self.localFileData = data; self.setState({ filename: file.name || 'unknown', fileData: data, fileSize: file.size, fileType: file.type }); });
return alert('The file size cannot exceed 1m.'); var type = 'data:' + image.type + ';base64,'; util.readFileAsBase64(image, function(base64) { ReactDOM.findDOMNode(self.refs.uploadImg).value = '';
// TODO: Differenciate between input types /** * Generate a fingerprint for a file which will be used the store the endpoint * * @param {File} file * @param {Object} options * @param {Function} callback */ export default function fingerprint(file, options) { if (isReactNative()) { return Promise.resolve(reactNativeFingerprint(file, options)); } return Promise.resolve([ "tus-br", file.name, file.type, file.size, file.lastModified, options.endpoint ].join("-")); }
// DirectoryReader interface describe('File', function () { it('file.spec.39 constructor should be defined', function () { expect(File).toBeDefined(); // eslint-disable-line no-undef expect(typeof File).toBe('function'); }); it('file.spec.40 should be define File attributes', function () { var file = new File(); // eslint-disable-line no-undef expect(file.name).toBeDefined(); expect(file.type).toBeDefined(); expect(file.lastModifiedDate).toBeDefined(); expect(file.size).toBeDefined(); }); });
public static upload({ httpClient, dataURI, entityKey, attributeName, file, isImage, }: IUploadParams): Promise<HttpResponse> { let uri = this._buildUri(dataURI, entityKey, attributeName); if (isImage) { uri += "?$rawPict=" + file.type; } // FIXME - real crappy not to return some piece of information to refresh entity return httpClient.post({ uri, data: file, binary: true, }); }
/** * Converts a file to base64 * * @param {File} file * * @return {String} Base64 */ static async convertFileToBase64(file) { checkParam(file, 'file', File, true); return await new Promise((resolve) => { let reader = new FileReader(); reader.onload = (e) => { let base64 = e.target.result; base64 = base64.replace('data:' + file.type + ';base64,', ''); resolve(base64); } reader.readAsDataURL(file); }); }
.on('drop', (event) => { let file = event.originalEvent.dataTransfer.files[0]; let image = mimeTypes.includes(file.type);
resolve({ content: e.target.result, type: file.type, name: file.name });
`${instanceURL}/content/${name}`, data, file.type );
// DirectoryReader interface describe('File', function () { it('file.spec.39 constructor should be defined', function () { expect(File).toBeDefined(); // eslint-disable-line no-undef expect(typeof File).toBe('function'); }); it('file.spec.40 should be define File attributes', function () { var file = new File(); // eslint-disable-line no-undef expect(file.name).toBeDefined(); expect(file.type).toBeDefined(); expect(file.lastModifiedDate).toBeDefined(); expect(file.size).toBeDefined(); }); });
//DirectoryReader interface describe('File', function () { it("file.spec.39 constructor should be defined", function () { expect(File).toBeDefined(); expect(typeof File).toBe('function'); }); it("file.spec.40 should be define File attributes", function () { var file = new File(); expect(file.name).toBeDefined(); expect(file.type).toBeDefined(); expect(file.lastModifiedDate).toBeDefined(); expect(file.size).toBeDefined(); }); });