storj / team-metainfo

GNU Affero General Public License v3.0
0 stars 0 forks source link

Prepare metainfo endpoint to accept metadata with BeginObject #105

Closed mniewrzal closed 2 years ago

mniewrzal commented 2 years ago

User metadata is accepted only with CommitObject request. We would like to do this also at the beginning of upload. The main motivation is integration with gateway where while MPU metadata is provided only at the beginning. On metainfo side we need to update protobuf definition for begin object request and write it up with endpoint method. Metabase is already accepting metadata while begin object.

Acceptance Criteria:

storjBuildBot commented 2 years ago

Change https://review.dev.storj.io/c/storj/common/+/7300 mentions this issue.

mniewrzal commented 2 years ago

So I made a simple test case to check how request with empty or nil metadata will be unmarshaled and it looks there is no difference how nil and []byte is marshaled

    request := &pb.ObjectBeginRequest{
        EncryptedMetadata: []byte{},
    }
    data, err := pb.Marshal(request)
    require.NoError(t, err)

    var after pb.ObjectBeginRequest
    err = pb.Unmarshal(data, &after)
    require.NoError(t, err)
    assert.Equal(t, []byte(nil), after.EncryptedMetadata)

    request = &pb.ObjectBeginRequest{
        EncryptedMetadata: nil,
    }
    data, err = pb.Marshal(request)
    require.NoError(t, err)

    err = pb.Unmarshal(data, &after)
    require.NoError(t, err)
    require.Equal(t, []byte(nil), after.EncryptedMetadata)

    request = &pb.ObjectBeginRequest{
        EncryptedMetadata: []byte{1},
    }
    data, err = pb.Marshal(request)
    require.NoError(t, err)

    err = pb.Unmarshal(data, &after)
    require.NoError(t, err)
    require.Equal(t, []byte{1}, after.EncryptedMetadata)

So for CommitObject to avoid overriding metadata we would need to add an additional flag like OverrideMetadata.

storjBuildBot commented 2 years ago

Change https://review.dev.storj.io/c/storj/storj/+/7308 mentions this issue.

storjBuildBot commented 2 years ago

Change https://review.dev.storj.io/c/storj/storj/+/7301 mentions this issue.

storjBuildBot commented 2 years ago

Change https://review.dev.storj.io/c/storj/common/+/7366 mentions this issue.

mniewrzal commented 2 years ago

For now, CommitObject will always get metadata from gateway (merged user metadata with etag) so we don't need to modify anything else for now.