mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-11-15 14:43:46 +01:00
Support metadata when uploading objects
Add contentType and contentEncoding options to sendStream(). These options will set the corresponding metadata on the object. This changes the API. The fourth argument to sendStream() used to be the source md5. Now, it's an options object and the source md5 is a property of that object.
This commit is contained in:
@@ -361,12 +361,9 @@ describe('GcsPersistorTests', function () {
|
||||
|
||||
describe('when a hash is supplied', function () {
|
||||
beforeEach(async function () {
|
||||
return GcsPersistor.sendStream(
|
||||
bucket,
|
||||
key,
|
||||
ReadStream,
|
||||
'aaaaaaaabbbbbbbbaaaaaaaabbbbbbbb'
|
||||
)
|
||||
return GcsPersistor.sendStream(bucket, key, ReadStream, {
|
||||
sourceMd5: 'aaaaaaaabbbbbbbbaaaaaaaabbbbbbbb'
|
||||
})
|
||||
})
|
||||
|
||||
it('should not calculate the md5 hash of the file', function () {
|
||||
@@ -388,6 +385,25 @@ describe('GcsPersistorTests', function () {
|
||||
})
|
||||
})
|
||||
|
||||
describe('when metadata is supplied', function () {
|
||||
const contentType = 'text/csv'
|
||||
const contentEncoding = 'gzip'
|
||||
|
||||
beforeEach(async function () {
|
||||
return GcsPersistor.sendStream(bucket, key, ReadStream, {
|
||||
contentType,
|
||||
contentEncoding
|
||||
})
|
||||
})
|
||||
|
||||
it('should send the metadata to GCS', function () {
|
||||
expect(GcsFile.createWriteStream).to.have.been.calledWith({
|
||||
metadata: { contentType, contentEncoding },
|
||||
resumable: false
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('when the upload fails', function () {
|
||||
let error
|
||||
beforeEach(async function () {
|
||||
|
||||
Reference in New Issue
Block a user