Chromium Code Reviews| Index: Source/core/fileapi/File.cpp |
| diff --git a/Source/core/fileapi/File.cpp b/Source/core/fileapi/File.cpp |
| index e541d7923cb1475bdd9063545c3ff44aad2159cb..217674960098bbc5dbe3856113bfecc102acf60c 100644 |
| --- a/Source/core/fileapi/File.cpp |
| +++ b/Source/core/fileapi/File.cpp |
| @@ -31,6 +31,7 @@ |
| #include "core/fileapi/FilePropertyBag.h" |
| #include "platform/FileMetadata.h" |
| #include "platform/MIMETypeRegistry.h" |
| +#include "platform/blob/BlobData.h" |
| #include "public/platform/Platform.h" |
| #include "public/platform/WebFileUtilities.h" |
| #include "wtf/CurrentTime.h" |
| @@ -101,7 +102,6 @@ File* File::create(const HeapVector<BlobOrStringOrArrayBufferViewOrArrayBuffer>& |
| lastModified = static_cast<double>(options.lastModified()); |
| else |
| lastModified = currentTimeMS(); |
| - |
| ASSERT(options.hasEndings()); |
| bool normalizeLineEndingsToNative = options.endings() == "native"; |
| @@ -113,6 +113,19 @@ File* File::create(const HeapVector<BlobOrStringOrArrayBufferViewOrArrayBuffer>& |
| return File::create(fileName, lastModified, BlobDataHandle::create(blobData.release(), fileSize)); |
| } |
| +File* File::create(char* encodedImage, size_t size, const String& mimeType) |
|
Justin Novosad
2015/08/20 20:38:43
encodedImage -> data
size -> bytes
xlai (Olivia)
2015/08/20 21:36:29
Acknowledged.
|
| +{ |
| + ASSERT(encodedImage); |
| + |
| + OwnPtr<BlobData> blobData = BlobData::create(); |
| + blobData->setContentType(mimeType); |
| + blobData->appendBytes(encodedImage, size); |
| + long long blobSize = blobData->length(); |
| + |
| + // create blob as the type of file with two additional attributes -- name and lastModificationTime |
| + return File::create("", currentTimeMS(), BlobDataHandle::create(blobData.release(), blobSize)); |
| +} |
| + |
| File* File::createWithRelativePath(const String& path, const String& relativePath) |
| { |
| File* file = new File(path, File::AllContentTypes, File::IsUserVisible); |