Repository: usememos/memos
File: api/v1/resource.go (Go)

Code before:
		}
		filePath := filepath.FromSlash(localStoragePath)
		if !strings.Contains(filePath, "{filename}") {
			filePath = filepath.Join(filePath, "{filename}")
		}
		filePath = filepath.Join(s.Profile.Data, replacePathTemplate(filePath, create.Filename))

		dir := filepath.Dir(filePath)
		if err = os.MkdirAll(dir, os.ModePerm); err != nil {
			return fmt.Errorf("Failed to create directory: %s", err)
		}
		dst, err := os.Create(filePath)
		if err != nil {
			return fmt.Errorf("Failed to create file: %s", err)
		}
		defer dst.Close()
		_, err = io.Copy(dst, r)
		if err != nil {
			return fmt.Errorf("Failed to copy file: %s", err)
		}

		create.InternalPath = filePath
		return nil
	}

	// Others: store blob into extern service, such as S3
	storage, err := s.GetStorage(ctx, &store.FindStorage{ID: &storageServiceID})
	if err != nil {
		return fmt.Errorf("Failed to find StorageServiceID: %s", err)
	}
	if storage == nil {
		return fmt.Errorf("Storage %d not found", storageServiceID)
	}
	storageMessage, err := ConvertStorageFromStore(storage)
	if err != nil {
		return fmt.Errorf("Failed to ConvertStorageFromStore: %s", err)
	}

	if storageMessage.Type != StorageS3 {
		return fmt.Errorf("Unsupported storage type: %s", storageMessage.Type)
	}

	s3Config := storageMessage.Config.S3Config
	s3Client, err := s3.NewClient(ctx, &s3.Config{
		AccessKey: s3Config.AccessKey,
		SecretKey: s3Config.SecretKey,
		EndPoint:  s3Config.EndPoint,
		Region:    s3Config.Region,
		Bucket:    s3Config.Bucket,
		URLPrefix: s3Config.URLPrefix,
		URLSuffix: s3Config.URLSuffix,

Review comment (suggestion):
```suggestion
	// Others: store blob into external service, such as S3
```

Code after:
		}
		filePath := filepath.FromSlash(localStoragePath)
		if !strings.Contains(filePath, "{filename}") {
			filePath = filepath.Join(filePath, "{filename}")
		}
		filePath = filepath.Join(s.Profile.Data, replacePathTemplate(filePath, create.Filename))

		dir := filepath.Dir(filePath)
		if err = os.MkdirAll(dir, os.ModePerm); err != nil {
			return fmt.Errorf("Failed to create directory: %s", err)
		}
		dst, err := os.Create(filePath)
		if err != nil {
			return fmt.Errorf("Failed to create file: %s", err)
		}
		defer dst.Close()
		_, err = io.Copy(dst, r)
		if err != nil {
			return fmt.Errorf("Failed to copy file: %s", err)
		}

		create.InternalPath = filePath
		return nil
	}

	// Others: store blob into external service, such as S3
	storage, err := s.GetStorage(ctx, &store.FindStorage{ID: &storageServiceID})
	if err != nil {
		return fmt.Errorf("Failed to find StorageServiceID: %s", err)
	}
	if storage == nil {
		return fmt.Errorf("Storage %d not found", storageServiceID)
	}
	storageMessage, err := ConvertStorageFromStore(storage)
	if err != nil {
		return fmt.Errorf("Failed to ConvertStorageFromStore: %s", err)
	}

	if storageMessage.Type != StorageS3 {
		return fmt.Errorf("Unsupported storage type: %s", storageMessage.Type)
	}

	s3Config := storageMessage.Config.S3Config
	s3Client, err := s3.NewClient(ctx, &s3.Config{
		AccessKey: s3Config.AccessKey,
		SecretKey: s3Config.SecretKey,
		EndPoint:  s3Config.EndPoint,
		Region:    s3Config.Region,
		Bucket:    s3Config.Bucket,
		URLPrefix: s3Config.URLPrefix,
		URLSuffix: s3Config.URLSuffix,